The recent wave of OA from major manufacturers is indeed a bit intensive, especially Microsoft, Google, TikTok, and Amazon are all posting questions like crazy. I just finished this set from Microsoft. The overall difficulty is above average. It is not a pure template question, but it is not particularly tricky. The core is to examine the understanding of data structure + the stability of code implementation. Let’s sort out the two questions this time and give them a reference for students preparing for Microsoft OA.
Q1: Maximum number of string operations
Question meaning:Each time you can select three consecutive characters s[i], s[i+1], s[i+2]. If the first two are equal and the third one is different, change the third one to be the same as the first two. Ask how many times it can be operated at most.
Idea:Once two consecutive identical characters appear, they can "spread to the right", turning the following different characters into the same one. That is to say, each block of consecutive identical characters with a length ≥ 2 can continue to swallow different characters on the right until a new consecutive block is encountered. So the essence is counting: how many characters can be assimilated by the previous "continuous block". You can traverse from left to right and record the current length of the same consecutive characters. If the length is ≥2 and the subsequent characters are different, you can perform an operation and continue to extend the continuous length.
Q2: Session authentication system
Question meaning:It is to implement a token system with expiration time. Each token has an expiration time = current time + TTL when generated. Supports three operations: generation, renewal, and querying the current unexpired quantity. The key point is: at the same point in time, you must first determine which tokens have expired; if the expiration time is exactly equal to the current time, it is considered expired and cannot be renewed or counted.
Idea:Use a hash table to store token_id -> expiration time. During each operation, delete all expired ones first (or determine whether they are expired when accessing). Generate directly writes the new expiration time; renew only updates the expiration time when the token exists and has not expired; count counts the current number of unexpired tokens.
OA Sprint Suggestions for Major Companies
If you are currently using OA from Microsoft, Google, TikTok, or Amazon, you must focus on "stability" rather than just pursuing excellence. Boundary conditions must be practiced, and details such as expired judgment, subscript out-of-bounds, and complexity control must not be lost; at the same time, the rhythm of the real exam must be simulated, and one must be trained in a time-limited environment. The goal is to stabilize the AC within 30 minutes, rather than repeatedly debugging. Nowadays, the real gap between many OAs is not whether they are capable, but whether they are stable. If you are stuck on a certain type of questions, or want to get more of the latest real questions, or do high-intensity simulations, you may even need to Practical auxiliary support , you can contact us and we will help you one-on-one to improve your rhythm and pass rate.