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 🚀 (yeah written by AI but questions are real)