mSpot Interview Question
Software Engineer / DevelopersCountry: United States
Let me start with an example
A = {0,2,4,5,0,1,2,3,0}
step 1 : sort it
A' = {0,0,0,1,2,2,3,4,5}
step 2 : remove duplicates along with print possible two element sets;
output will be :
sets : {0,0},{2,2}
A'' = {0,1,2,3,4,5}
now apply the simple algorithm to print all 2 element sets
for i=1:sizeof(A'')-1
for j=i+1:sizeof(A'')
output {A''[i],A''[j]}
step1 sorting
- vincent January 15, 2013step2 dynamic programming + memorization