mSpot Interview Question for Software Engineer / Developers


Country: United States




Comment hidden because of low score. Click to expand.
0
of 0 vote

step1 sorting
step2 dynamic programming + memorization

- vincent January 15, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

why dp? don't even need sort. this is just like the perfect shuffle cards problem. only thing to notice is that there can be duplicate numbers, so probably use hashtable to take care.

- zyfo2 January 16, 2013 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

I think a for{for{}} loop is ok

- Anonymous January 16, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

the time complexity is ok.
however keep it generalized for n...cant keep on adding for loops everytime n increases

- bbarodia January 16, 2013 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

psuedoocde...
We can do this as follows..
1)first sort the array.
2)Then remove the duplicate elements .
3)then taking double {for{for{}}} to make combinations

- pinnacle January 16, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

I think you don't need to sort and remove duplicates if you will use two for loops eventually.

for(i=0;i<n-1; ++i) {
    for(j=i+1; j<n; ++j){
        if (a[i] != a[j]) printf("(%d,%d) ",a[i],a[j]); 
    }
}

- sungwonl January 17, 2013 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

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]}

- sonesh January 21, 2013 | Flag Reply


Add a Comment
Name:

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.

Books

is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.

Learn More

Videos

CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.

Learn More

Resume Review

Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.

Learn More

Mock Interviews

Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.

Learn More