@Harshit: These are a few unanswered questions that came to mind when I 
read your solution attempt: What do you do with negative elements? What is 
the -12th prime number? How do you deal with overflow in the cases where 
you have a lot of large prime numbers and the product exceeds your native 
data types?
 
Dave

On Saturday, May 19, 2012 2:29:52 PM UTC-5, harshit pahuja 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 view this discussion on the web visit 
https://groups.google.com/d/msg/algogeeks/-/WEW0M5VUUVEJ.
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.

Reply via email to