I recently faced the interview of Microsoft for summer internship
I am posting the questions asked to me in the written test and interview
Written exam was a subjective test comprising only 3 questions, 2 for coding and 1 for testing. The questions are as :-
1). There is a concept of some magic numbers like we have numbers from 1 to a big number and in first iteration we delete the numbers leaving one gap like initially numbers are : 1 2 3 4 5 6 7 8……… After first iteration we delete numbers 2 4 6 8….. Therefore now the remaining numbers are 1 3 5 7 9 11 13 15 17 19. In second iteration we delete numbers leaving two gaps, hence after it left no.s are 1 3 7 9 13 15 19 21…… then we delete no.s leaving 3 gaps and hence left nos. are 1 3 7 13 15 19 25…….The numbers which are never deleted are termed as magic number. Write a function, given a number, that weather a number is a magic no. or not
2). There are 2 lists (both singly non-circular). Both lists merge at one common node. Write a function returning pointer to a node at which the two lists merge and NULL if they do not merge.
3). You are given above function to use, but you cannot access the code of the function implemented in Q.2. Now you have to write the test cases for the same.
I did first two questions correct as written in the comments column and got selected for the interview. I will be posting the interview question soon.
For solutions refer to the “comments” column. Or for any querries post it in the comments..