use sum calculated in 2nd array as index for hashing..and index for second
array as value of hashing;
for example
original array:20 , -9 , 3 , 1, 5 , 0, -6 , 9
array after addition:20 , 11,14,15,20,20,14,23
according to above example hashing will be like this
k[20]=0;
k{11]=1;
k[14]=2;
k[15]=3;
again when now 20 comes so collision occurs as k[20] is already 1.
therefore all the elements from index( k[20]+1) to 4(coz next 20 occurs at
dis location) form the required string..On Thu, Jul 21, 2011 at 12:43 AM, sagar pareek <[email protected]>wrote: > how collision occur at 14 and 20 > actually i m not getting hash function > Thanks in advance > > On Thu, Jul 21, 2011 at 12:39 AM, Kamakshii Aggarwal < > [email protected]> wrote: > >> @sagar: i read contiguous afterwards therefore i deleted my post... >> and for ankur's approach >> : >> original array:20 , -9 , 3 , 1, 5 , 0, -6 , 9 >> array after addition:20 , 11,14,15,20,20,14,23 >> >> now when u hash second array elements >> then u fill find collision at value 14 and 20 >> this means terms b/w 1st 14 and 2nd 14 adds t0 0.(1,5,0,-6)... >> is it clear now? >> >> >> >> On Thu, Jul 21, 2011 at 12:22 AM, Kamakshii Aggarwal < >> [email protected]> wrote: >> >>> >>> a little mistake in ankur's solution >>> 20 , -9 , 3 , 1, 5 , 0, -6 , 9 >>> 20 , 11,14,15,20,20(instead of 0),14,23 >>> now if sum of two consecutive terms is same then this means a 0 >>> exists.and hence it can be printed as a subarray..else ankur's sol works >>> fine..:) >>> >>> >>> On Thu, Jul 21, 2011 at 12:06 AM, sagar pareek <[email protected]>wrote: >>> >>>> @ankur.... >>>> >>>> pls explain through an example by taking above problem..... >>>> >>>> >>>> On Wed, Jul 20, 2011 at 10:52 PM, SAMMM <[email protected]>wrote: >>>> >>>>> >>>>> >>>>> Nice solution dude .........!!!! Like that one .... >>>>> >>>>> -- >>>>> You received this message because you are subscribed to the Google >>>>> Groups "Algorithm Geeks" group. >>>>> To post to this group, send email to [email protected]. >>>>> To unsubscribe from this group, send email to >>>>> [email protected]. >>>>> For more options, visit this group at >>>>> http://groups.google.com/group/algogeeks?hl=en. >>>>> >>>>> >>>> >>>> >>>> -- >>>> **Regards >>>> SAGAR PAREEK >>>> COMPUTER SCIENCE AND ENGINEERING >>>> NIT ALLAHABAD >>>> >>>> -- >>>> You received this message because you are subscribed to the Google >>>> Groups "Algorithm Geeks" group. >>>> To post to this group, send email to [email protected]. >>>> To unsubscribe from this group, send email to >>>> [email protected]. >>>> For more options, visit this group at >>>> http://groups.google.com/group/algogeeks?hl=en. >>>> >>> >>> >>> >>> -- >>> Regards, >>> Kamakshi >>> [email protected] >>> >> >> >> >> -- >> Regards, >> Kamakshi >> [email protected] >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Algorithm Geeks" group. >> To post to this group, send email to [email protected]. >> To unsubscribe from this group, send email to >> [email protected]. >> For more options, visit this group at >> http://groups.google.com/group/algogeeks?hl=en. >> > > > > -- > **Regards > SAGAR PAREEK > COMPUTER SCIENCE AND ENGINEERING > NIT ALLAHABAD > > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/algogeeks?hl=en. > -- Regards, Kamakshi [email protected] -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
