Microsoft Interview Question for Software Engineer / Developers






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

1)Form a BST using first Array...

2)Now for each element in 2nd array...search for correponding element in BST....

3)if that element is present delete it and continue for the whole array....

- keshav January 24, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

In place. O(n*log(n))

void intersection(int[] a, int[] b, int[] solution)
{int i=0,j=0r=0;
 a.sort();
  b.sort();
while((i<a.length)&&(j<b.length))
 {
   if(a[i]==b[j])
   {
     solution[r]=a[i];
     r++;
     i++;
     j++;
   }
   else if(a[i]<b[j]){
          i++;

    }else{
      j++;
    }
 }
}

- gerardo.ruiz@aiesec.net February 06, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

let the lengths of the two arrays be m and n and m<n
sort the small array--O(mlogm)
binary search all the n elements of bigger array in the small array.--O(nlogm)
total complexity--O((n+m)logm)

- Anonymous January 25, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

let the lengths of the two arrays be m and n and m<n
create a hashmap from the smaller array --> O(m).
For every element in the larger array check if the element exists in the hashmap. if it does then push into a vector --> O(n)
Time Complexity: O(m) + O(n) ==> O(n) {since m<n}
Space Complexity: O(m) + O(m) ==> O(m)

- GekkoGordan January 28, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

1) Create an array of size 256 and of type int to hold all ASCII values.
2) Initialize the whole array to 0
3) Iterate through the first array and set the respected index in array according to their ASCII values to 1.
4) Iterate through the second array and check which elements have 1 in the array according to their ASCII.

Time complexity:
O(256) + O(m) + O(n) = O(n)

- Usman January 30, 2011 | 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