ohh ok i got it.. thanx :) On Sat, Jul 2, 2011 at 12:48 AM, sunny agrawal <sunny816.i...@gmail.com>wrote:
> it is (2,4] not [2,4]. > open interval, close interval ......... consider (i,j] as [i+1,j] > > because a[i] = sum of values from 0 to i > and a[j] = sum of values from 0 to j > if a[i] = a[j] then it means sum does not changes between a[i] to a[j] > > so from i+1 to j there are equal no of 1's and -1's > or in other words equal no of 0's and 1's > > > On Sat, Jul 2, 2011 at 12:42 AM, Anika Jain <anika.jai...@gmail.com>wrote: > >> @sunny: in a[2,4] has 2 1s and one 0 then how is it a solution? i mean i >> didnt get wen a[i]==a[j] then a[i,j] is a solution case.. >> >> On Fri, Jul 1, 2011 at 4:13 PM, sunny agrawal <sunny816.i...@gmail.com>wrote: >> >>> Take an array of size of the length of the string. >>> fill the array positions with one where string contains 1, and -1 where >>> it is 0 >>> >>> Now for each i (1,n-1) perform the following operation >>> a[i] = a[i-1] + a[i] >>> now a[i] will contains sum of values from a[0] to a[i] in original array. >>> >>> Now only thing remains to find is two indexes in this array such that >>> a[i] = a[j] >>> where ever this condition is met ( i,j ] is a solution >>> >>> or if for some i a[i] = 0 in this case [0,i] will be a solution >>> >>> this can be done using hashing >>> hash the values in the array of size 2*n+1. as range of values is -n to n >>> and keep track of max interval. >>> >>> >>> >>> >>> On Fri, Jul 1, 2011 at 3:22 PM, Anantha Krishnan < >>> ananthakrishnan....@gmail.com> wrote: >>> >>>> Given a string containing 0's and 1's. One would need to find the >>>> longest sub-string such that the count of 0's is equal to the count of 1's >>>> in the largest sub string. >>>> >>>> Regards >>>> Anantha Krishnan >>>> >>>> -- >>>> You received this message because you are subscribed to the Google >>>> Groups "Algorithm Geeks" group. >>>> To post to this group, send email to algogeeks@googlegroups.com. >>>> To unsubscribe from this group, send email to >>>> algogeeks+unsubscr...@googlegroups.com. >>>> For more options, visit this group at >>>> http://groups.google.com/group/algogeeks?hl=en. >>>> >>> >>> >>> >>> -- >>> Sunny Aggrawal >>> B-Tech IV year,CSI >>> Indian Institute Of Technology,Roorkee >>> >>> >>> -- >>> You received this message because you are subscribed to the Google Groups >>> "Algorithm Geeks" group. >>> To post to this group, send email to algogeeks@googlegroups.com. >>> To unsubscribe from this group, send email to >>> algogeeks+unsubscr...@googlegroups.com. >>> For more options, visit this group at >>> http://groups.google.com/group/algogeeks?hl=en. >>> >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Algorithm Geeks" group. >> To post to this group, send email to algogeeks@googlegroups.com. >> To unsubscribe from this group, send email to >> algogeeks+unsubscr...@googlegroups.com. >> For more options, visit this group at >> http://groups.google.com/group/algogeeks?hl=en. >> > > > > -- > Sunny Aggrawal > B-Tech IV year,CSI > Indian Institute Of Technology,Roorkee > > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group. > To post to this group, send email to algogeeks@googlegroups.com. > To unsubscribe from this group, send email to > algogeeks+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/algogeeks?hl=en. > -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.