Sachin Chitale,
Dude the xoring operation will give us xor of numbers with freq 1 and 3
respectively. How do you filter out the number with the frequency 3??
On Tuesday, February 12, 2013 11:44:08 PM UTC+5:30, Sachin Chitale wrote:
use ex-or operation for all array elements..
a^a=0
a^a^a=a
@Rashmi: I did not get your approach. I do not get emails from the group
just in case you have posted a solution :( What do you mean by keeping a
count? Also, are you using a hashmap? If yes, whats ur K,V?
#Pralay
On Tue, Feb 12, 2013 at 10:00 AM, rashmi i rash...@gmail.com wrote:
Hey Pralay,
Search for BitSet/BitVector in java .
On Tue, Feb 12, 2013 at 11:44 PM, Sachin Chitale
sachinchital...@gmail.comwrote:
use ex-or operation for all array elements..
a^a=0
a^a^a=a
On Sun, Feb 10, 2013 at 8:22 AM, Mohanabalan D B
mohanabala...@gmail.comwrote:
can use counting sort
On
@Sachin Chitale : Very good approach dude .
thumbs up +1
--
Arun Singh Chauhan
Engineer (RnD 2), Samsung Electronics
Software Engineering Lab, Noida
On Tuesday, February 12, 2013 11:44:08 PM UTC+5:30, Sachin Chitale wrote:
use ex-or operation for all array elements..
a^a=0
a^a^a=a
On
The xor approach only works if there are no values which occur only
once. But the problem statement indicates that some numbers occur
once, some occur twice, and one occurs three times. So you will end up
with prod equal to the xor of all of the values which occur once or
three times. Put that in
Hi Guys,
Came across this interesting question :
Given an integer N, find out all pairs of numbers a,b such that a^2+b^2 = N.
My approach is to find the floor of square root of N, and then try all
possible combinations from 1 to sqrt(N). Just wonder if I can do anything
better in the complex
Replace all elements of array by its square.and sort it
Now question is to find two nos in the array such that their sum is N.
For this take two pointers min and max
Initialize min to 0 and max to n-1(n-size of array)
1.find the sum a[min]+a[max]
2.if sumN max=max-1
if sumN min=min+1
if sum==N we
Guneesh,
Thanks for the reply.
I interpret ur answer as follows:
If N = say, 50
the two combinations are (1,7) and (5,5).
Acc to you, first find sqrt(50) = 7
fill in 1,4,9,16,25,36,49 in an array.
Then have min = 0, max = 6 and get all combinations in one pass over the
array, right?
So, the