Microsoft 26NG OA Review|20 minutes to pass, both questions are "Microsoft style".

333 Views
No Comment

Just had it done the other day. Microsoft 26NG OA, the whole experience is very smooth, a total of two questions, the total time of about 20 minutes to submit. The overall difficulty is medium, the idea is clear, there are not too many pitfalls, belongs to Microsoft's consistent style: valuing clear thinking, clean code, rather than deliberately difficult.

Since I've done hundreds of OAs from major companies since August (Microsoft, Google, Amazon, TikTok, Meta, all of them), this Microsoft OA basically belongs to the category of "I know how to write it at a glance". Here, I'll organize the topics and write my own thoughts, so that students who are still preparing can use them as a reference.

Microsoft 26NG OA

Q1 - Maximize Sum by Choosing from Two Arrays

Problem
Given two arrays r1 And r2 of the same length N, you must choose exactly K elements from r1 And N-k elements from r2.
At position I, you may choose either r1[i] or r2[i], but not both.
Return the maximum possible total sum.

Analysis of ideas

This question is actually a very classic "gain selection" (gain selection) problem, greedy direct seconds.

My approach is simple and consistent:

  1. Assume for a moment that r2 is selected for all positions
    • Because r2 chose n-k but we'll just select them all first and replace the k later.
    • Initial sum = sum(r2).
  2. Calculate the "gain from switching to r1" for each position.
gain[i] = r1[i] - r2[i]
  1. The larger the gain, the more r1 should be selected.
  2. Sort the gains from largest to smallest and select the top k gains
  3. Answer = sum(r2) + sum of the first k largest gains

Why is this greed optimal?

Since there are only two choices for each position and they are completely independent, maximizing the sum is maximizing the local gain, and gain ordering is the only reasonable strategy.

This question is basically in the typical style of Microsoft OA:
It's not hard, but it must be written cleanly and logically.

Q2 - Minimum Edits to Form the Lexicographically Smallest Palindrome

Problem
Given a string S, you are allowed to modify characters.
You want to make the string rearrangeable into a palindrome.
Among all solutions that require the minimum number of edits, return the lexicographically smallest possible palindrome.

Breakdown of key points

There is an ironclad rule for wanting a string to be rearranged into a palindrome:

At most, a character can appear an odd number of times.

So the question becomes two steps:

  1. Minimum modification → Turn odd count characters into even if possible.
  2. smallest dictionary sequence → Try to place small characters in the left half when constructing palindromes

Specific practices

① Statistical frequency, number of treatment odd times

  • Count all character frequencies
  • Find all odd numbered characters.
  • Each modification allows two odd → even
    → and thus the number of modifications is minimized = odd_count / 2

In order to keep the final echo dictionary order as small as possible, I'll prioritize large odd characters towards small ones, so that frequency processing and dictionary order optimization can be done at the same time.

② Constructs a palindrome with minimal dictionary ordering

With the frequency adjusted, the construction method is natural:

  • Left half: fill in from smallest to largest (e.g. 'a' → 'z')
  • Center character: if there is an odd, put the odd character with the smallest number of occurrences
  • Right half: write the left half backwards

The whole is then guaranteed to be the dictionary-ordered minimum solution in the least-modified scheme.

Overall experience with Microsoft 26NG OA

This OA returned to Microsoft's usual focus of examination:

  • Clear logical derivation
  • Fundamentals of data structures (arrays, frequency statistics, sorting)
  • Code style and detailing
  • It's not about showmanship, it's about consistency.

There aren't any tricky test cases or particularly complicated corner cases.
Just think through the logic and it's a straight AC.

I got through both questions in about 20 minutes, at a pace of 5-10 minutes per question.

If you are also preparing for Microsoft / Amazon / Google school recruitment OA

Programhelp Specializing in technical support services for OA of major manufacturers, we provide the following assistance for online review platforms such as HackerRank and CodeSignal:

  • Online assessment code assistance and implementation: covers arrays, strings, simulations, constructions, greediness, graph theory, DP, and other mainstream question types
  • Ensure that all test cases pass: Aim for runnable, maintainable code
  • Results oriented, no fee for no success
  • Multi-language supportJava / Python / C++

The whole process is accomplished through remote collaboration tools such as ToDesk, with a seamless interface and natural operation that does not affect the normal submission experience, and is applicable to all kinds of programming tests on platforms such as CodeSignal, HackerRank, and Codility.

We have accumulated a lot of understanding of OA question types and scoring mechanisms of major manufacturers (Microsoft / Google / Amazon / TikTok / Meta), and we are also familiar with the differences in the operating environments of different platforms, so we can help candidates maintain stable performance in a tight time frame.

author avatar
Jory Wang Amazon Senior Software Development Engineer
Amazon senior engineer, focusing on the research and development of infrastructure core systems, with rich practical experience in system scalability, reliability and cost optimization. Currently focusing on FAANG SDE interview coaching, helping 30+ candidates successfully obtain L5/L6 Offers within one year.
END
 0