Microsoft interview questions | Microsoft 26 NG OA | Complete review of the latest Hard questions in December

34 Views
No Comment

This December'sMicrosoft 26NG OA is still two programming questions on the HackerRank platform. Overall style: medium-hard, solid test points, details determine life and death.
I also had a smooth AC this time, so I’ll share the questions and ideas while it’s hot. I hope you can also pass it.

Microsoft 2026 NG OA real questions (latest in December)

Problem 1 — Discounted Prices

You are given an array prices where prices[i] is the original price of the i-th item. For each item I, its selling price is prices[i] - prices[j], where j is the index of the first item to the right of I Such that prices[j] <= prices[i].
If there is no such j, the item is sold at its original price.
Return:

  • the total sum of all selling prices
  • the list of indices sold at original price (0-based)

Discount problem of the first <= on the right side (classic variant of monotonic stack)

The core of the question is to find:
To the right of each element, the first <= its value.

This is a typical "next smaller or equal element" problem, solved in one go using a monotonically increasing stack from right to left.

Core idea

  • Scan prices from right to left;
  • Use a stack that increases from bottom to top to store the processed price index;
  • Every time you encounter a new price, pop off all the tops of the stack that are strictly greater than it, because they cannot become discounts for this product;
  • If the top of the final stack is <=, it is its discount; if the stack is empty, there is no discount;
  • Easily add up the total price and record the bid without discount;
  • Finally, output the total price + the index list sold at the original price.

time complexity

O(n), each element is pushed/popped at most once.

Easy to make mistakes

  • Note that <=,no <.
  • Processing from right to left makes it easier to maintain monotonous structures.
  • Subscripts without discounts can be processed and sorted according to the requirements of the question (interviewers generally do not get stuck, but they must be clear when writing).

Problem 2 — Prefix Permutation Segment Check

Given a permutation p of 1..n, for every k From 1 to n, determine whether there exists a contiguous subarray that forms a permutation of 1..k.
Output a binary string s of length n where s[k-1] = '1' if such a segment exists.

Permutation Prefix judgment (prefix window min/max)

Given a permutation p, ask whether there is a continuous subarray for each k, which is a permutation of 1..k.

Key observations

If the position of this bunch of numbers 1..k in the entire array is:

Minimum position = L
Maximum position = R
and R – L + 1 == k

Then they occupy exactly one window, which is a legal segment.

algorithm

  • First record the position of each number pos[x];
  • Traverse k = 1..n:
    • update current cur_min, cur_max(That is the earliest/latest position where the prefix number appears);
    • if cur_max - cur_min + 1 == k, then output ‘1’, otherwise ‘0’.

time complexity

O(n)

Easy to make mistakes

  • The pos array must be 0-based, and the consistent gender is wrong.
  • When k=1, min=max=pos[1] must be ‘1’

How “Microsoft-flavored” are the two questions on Microsoft OA?

Microsoft OA style has always been relatively stable:

  • The routine is not tricky, but it pays great attention to "code quality + complexity + boundary processing".
  • When writing code on the spot, you usually don’t have much time to debug, so you need to be very skilled in writing O(n) methods.
  • The second question is a common Microsoft permutation reasoning question, which tests the logical rigor.

If you don't train enough, you will feel like "you have it in your head but you can't write it smoothly" for this type of question; but as long as you do it in the right direction, the code will not be complicated.

ProgramHelp Microsoft 2026 NG OA Special Assistance

This year's Microsoft 2026 NG OA is obviously more "volumey". Although the two Hackerrank questions are not over the top, they have detailed logic, many pitfalls, and tight time. This is also the reason why many students dropped points. We have accumulated real-scenario replays from multiple batches of students, including the latest version of question type changes in December, common stuck points, and boundary situations that are most likely to be misjudged.
If you want more stability, we can provide:

  • Real-time voice assistance: It will give you direction reminders and boundary tips during the question solving process. It will not do the operation for you, but it can help you avoid most traps.
  • 0 traces of remote online tutoring: The whole process is safe, does not trigger platform detection, and uses our stable and verified technical solution.
author avatar
jor jor
END
 0