yes O(n) solution posible..
1. traverse the first array..
2. for(i=1;i<=n;i++)
{ X[a[i]] = i ;
}
3. print array X[];
On Sat, Jan 1, 2011 at 10:42 PM, Soumya Prasad Ukil
<[email protected]>wrote:
> Is the second array really required, assuming intersection of both A & B is
> equal to either A or B?
>
> How about X[a[i]] = i?
>
>
> On 27 December 2010 21:24, Anand <[email protected]> wrote:
>
>> I have a two arrays
>>
>> One is
>>
>> 2 5 1 6 4 3
>>
>> other is
>>
>> 1 2 3 4 5 6.
>>
>> I want to make an array X which gives the index of its element on other
>> arrays.
>>
>> Meaning X[1] = 3 1 is element of the second array and 3 is the index of
>> element 1 in first array.
>>
>> How shall we get array X in O(nlogn).
>>
>> --
>> 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]<algogeeks%[email protected]>
>> .
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>
>
>
> --
> regards,
> soumya prasad ukil
>
> --
> 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]<algogeeks%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>
--
*Divesh*
(¨`·.·´¨) Always
`·.¸(¨`·.·´¨ ) Keep
(¨`·.·´¨)¸.·´Smiling!
`·.¸.·´" Life can give u 100's of reason 2cry,but u can give life 1000's
of reasons 2Smile"
--
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.