microsoft logo
Microsoft· SDE I

Microsoft SDE OA | March 2026

Posted
21 Mar 2026
440 reads

Summary

I recently completed a Microsoft Online Assessment and wanted to share the key thinking patterns that helped me tackle two problems related to sliding window and monotonic stack techniques.

How it went

Just finished a Microsoft OA and wanted to share the thinking patterns that helped.

Problem 1 — Think: "minimum window with a condition"

If you see a problem asking for the shortest subarray satisfying some constraint on its elements, your first thought should be Sliding Window + HashMap. The HashMap tracks frequency, and map.size() gives you distinct count for free. Classic shrink-from-left pattern once the condition is met.

Relevant practice: LC 3, LC 76, LC 904

Problem 2 — Think: "each element affected by the next smaller/equal"

If each element's value depends on the first element to its right that satisfies a comparison, that's a textbook Monotonic Stack problem. Build a decreasing stack of indices, resolve pending elements as you scan right.

Relevant practice: LC 739, LC 496, LC 1475

Takeaway: Neither problem was algorithmically hard — the only barrier is recognizing the pattern fast under time pressure. If you've drilled these two patterns, you'll feel right at home.

Good luck everyone 🚀

Questions asked (2)

  1. 01

    Shortest Subarray with Constraint (Sliding Window)

    Data Structures & Algorithms · Medium

    Problem 1 — Think: "minimum window with a condition"

    If you see a problem asking for the shortest subarray satisfying some constraint on its elements, your first thought should be Sliding Window + HashMap. The HashMap tracks frequency, and map.size() gives you distinct count for free. Classic shrink-from-left pattern once the condition is met.

  2. 02

    Next Smaller/Equal Element (Monotonic Stack)

    Data Structures & Algorithms · Medium

    Problem 2 — Think: "each element affected by the next smaller/equal"

    If each element's value depends on the first element to its right that satisfies a comparison, that's a textbook Monotonic Stack problem. Build a decreasing stack of indices, resolve pending elements as you scan right.

How they prepared

My preparation involved thoroughly drilling common algorithmic patterns, focusing particularly on quickly recognizing problems solvable by Sliding Window with HashMap and Monotonic Stack under time pressure. I believe that recognizing these patterns swiftly is crucial for success.

Know someone preparing? Send it to them:WhatsAppLinkedInX

Interviewed at Microsoft recently?

Write up your rounds while you still remember the questions. It helps the next person more than you would think.

Share your experience
Discussion 0

Questions for the author, or how your own interview compared.

Join the discussion

Sign in with Google to comment or ask the author a question.

No comments yet

Be the first to share your thoughts and start the discussion!