Microsoft Interview Question for SDE-2s

Country: United States
Interview Type: In-Person

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

I would go with simple approach to start:

//using psuedo code

class Seat
 - id: int
 - occupied: String

class Row
 - seats[] : Seat  #array of Seat 
 - nextAvailableSeatIndex
 - hasConsecutive(int k);
 - seat(int numberOfPeople)
 - fit(int numberOfPeople)

class Bus:
 - rows[]: Row #array of Row
 - booker: Booker

class Booker:
 - rows[]: Row #reference to the row
 - book(int K)
  - for each row in rows
    - if row.hasConsecutive(K)
      - return row;
  - var rowIndex : 0
  - var result: []
  - var count = K;
  - while (count > 0 && rowIndex < rows.length
   - result += rows[rowIndex].fit( count ); //fit much as possible. Returns seats filled
   - count = K - result.length
   - ++rowIndex;
 - return result;

- tnutty2k8 August 31, 2017 | Flag Reply

Add a Comment

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.


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


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