Grid with obstacles

Asked atMicrosoft
1Give yourself 5 minutes
2Answer out loud, not in your head
3Then compare with the answer below
0
Stuck? Show a way to structure it+
  1. 01Clarify allowed moves and whether the task counts paths or optimizes a score
  2. 02Represent blocked cells as unreachable rather than ordinary zero-valued cells
  3. 03Define a state for the current cell and transitions from legal predecessors
  4. 04Initialize the start and boundary cells carefully
  5. 05Compress to one row only after preserving the above-cell value

Reference answer

Then expect these follow-ups

  • What constraint would change your chosen approach?

    Tests: constraint adaptation

  • How would you test the edge cases before implementation?

    Tests: implementation extension

Hiring now

Software engineer roles are open right now

landed applies to roles like these for you, on each company’s own site, with answers written for the role.

Get 5x interviews10 free auto-applies. No card.
  • Java Full Stack - Software Engineer III

    Hudson Manpower · Farmington Hills, MI

  • Staff Software Engineer

    ServiceNow · San Diego, CALIFORNIA, United States

  • Staff Software Engineer, Sandbox Secrets (West Coast)

    Docker · Remote

Or practice this question first

Next question