Microsoft Interview Question for Software Engineer / Developers






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

// input board size and number x;

Use 2D array that is allocated dynamically;
declare an array board;
init board to all 0;

begin loop
get the input into pos
if from player 1, set 1 at pos on board
else if from play 2, set 2 at pos on board

check row on pos;
check column on pos;
check two diagonals on pos;
if any one of them contains x number consecutive 1 or 2;
corresponding player win and restart game
else if all pos on board are occupied, tie and restart game
else continue loop

end loop

- James May 10, 2006 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Some additions:
- initialize winner to FALSE
- initialize counter - to zero. when the counter increases to 9, the board is full = the while loop condition
- initialization of (-20) of the array
- Array of integers when player A assigns 1 and player 2 assigns 0
- when checking for win - sum up and check whether the value is 3 or 0
- switch to deferentaite the path that should be checked for each position. the corners requires 3 checks while the other positions require 2 checks
- the game can end without winner

- Eila June 02, 2006 | 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