@atul:- why we require 1st condition(check sum of the square of arr1 = arr2) ??
On Sun, May 20, 2012 at 1:10 PM, atul anand <atul.87fri...@gmail.com> wrote: > it can be done by doing set of operation on the data. > 1) check sum of the square of arr1 = arr2 > 2) sum of elements of arr1=arr2 > 3) xoring elements of arr1 and arr2 == 0 > > if all 3 condition are successful then..permutation found. > > On Sun, May 20, 2012 at 12:59 AM, HARSHIT PAHUJA > <hpahuja.mn...@gmail.com>wrote: > >> given 2 unsorted integer arrays a and b of equal size. Determine if b is >> a permutation of a. Can this be done in O(n) time and O(1) space ? >> >> >> >> >> please help me with my solution >> >> >> suppose a -- 3 5 4 >> b -- 4 3 5 >> >> now we replace a[i] with a[i]..th prime number and b with b[i] .. th >> prime number >> >> now array a becomes 5 11 7 >> array b becomes 7 5 11 >> >> now we take product of elements of array a and do the same with array b >> elements >> if product is equal then b is a permutation of a >> >> -- >> 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. > -- *DARPAN BAWEJA* *3rd year, I.T* *MNNIT Allahabad* -- 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.