Microsoft Interview Question
1,056 Interview Reviews |
Back to all Microsoft Interview Questions & Reviews
Interview questions and reviews posted anonymously by interview candidates
Interview Question for Engineer at Microsoft:
Given a square Grid of numbers, Considering all the numbers at the boundary as 1 layer and numbers just inside as another layer and so on how would you rotate each of the layers of the numbers by a given amount.
| Tags: | c++ programming, c See more , See less 8 |
Helpful Question?
Yes |
No
Inappropriate?
Answers & Comments (3)
Helpful Answer?
Yes |
No
Inappropriate?
Store the elements of the 1st layer (from set 1 array) into the 1st set 2 array.
Store the elements from the 1st set 2 array into the 1st set 3 array (offset by +1 - except for last element). Eg: 1st element in set 2 array equals 2nd element in set 3 array, 2nd element in set 2 array equals 3rd element in set 3 array, so on. Last element in set 2 array equals 1st element in set 3 array.
Store the elements from the 1st set 2 array back into the set 1 array - this "layer" is now rotated.
Repeat for all layers !
Helpful Answer?
Yes |
No
Inappropriate?
Members can
answer or comment on this question
–
Join Now (It's Free) or
Sign In



by ✳✳✳✳✳✳✳✳