Microsoft Interview Question for Software Engineer in Tests






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

It could be similar to 8 queens problem.

HashMap map = new Map(); // Map to keep track of all numbers already used.
void placeNumber(int pos) {
      if (pos = 8)
               return;

      for (int i = 1; i < 9; i++) {
            int existingPos = map.get(i);
            if (existingPos == pos) {
                      // You need to remove old entry from map, if you reach back there again by backtracking
                       map.remove(i);
             }
            if (!map.exists(i) && isPossible(pos, i) {
                      map.put(i, pos);
                      placeNumber(pos+1)
            }
      }

- anonymous July 01, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Sorry formatting is not correct figure was like
YXY
XXX
XXX
YXY
assume figure like above pattern where X are square blocks and Y are empty spaces where figure does not exist... so you have fill 1 -8 in all X places according to above conditions... hope m clear now

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

Y7Y 
314
586
Y2Y

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

More outputs and many more
Y7Y Y2Y Y2Y Y3Y
413 685 314 547
685 413 586 261
Y2Y Y7Y Y7Y Y8Y

The logic behind this is,
Start filling any number in first row. say Y5Y. and proceed further with the given rule

- Anonymous July 26, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

last two cases not valid, diagonally 6,7 are dere

- codez July 04, 2012 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

b[k] ={1,2,3,4,5,6,7,8}
m = 3
n = 3

V()
	for each i from 0 to n-1
		for each j from 0 to m-1
			if((a[i][j] != a[i+1][j] +/- 1) && (a[i][j] != a[i][j+1] +/- 1) && (a[i][j] != a[i-1][j] +/- 1) && (a[i][j] != a[i][j-1] +/- 1))
				return true
			else 
				return false
				
SS(k)
	if(k == 7)
		if(V())
			for each i from 0 to n-1
				for each j from o to m-1
					print a[i][j]
	for each i from 0 to n-1
		for each i from 0 to m-1
			if(!((i == 0 && j ==0 ) || (i == 0 && j ==2) || (i == 2 && j ==0) || (i == 2 && j ==2)))
				a[i][j] = b[k]
				SS(k+1)

- Prateek Caire September 23, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

b[k] ={1,2,3,4,5,6,7,8}
m = 3
n = 3

V()
for each i from 0 to n-1
for each j from 0 to m-1
if((a[i][j] != a[i+1][j] +/- 1) && (a[i][j] != a[i][j+1] +/- 1) && (a[i][j] != a[i-1][j] +/- 1) && (a[i][j] != a[i][j-1] +/- 1))
return true
else
return false

SS(k)
if(k == 7)
if(V())
for each i from 0 to n-1
for each j from o to m-1
print a[i][j]
return
for each i from 0 to n-1
for each i from 0 to m-1
if(!((i == 0 && j ==0 ) || (i == 0 && j ==2) || (i == 2 && j ==0) || (i == 2 && j ==2)))
a[i][j] = b[k]
SS(k+1)

- Anonymous September 23, 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