DEV Community

Cover image for Microsoft OA Medium-Level Problem Breakdown | Session Token Design + String Manipulation
programhelp-cs
programhelp-cs

Posted on

Microsoft OA Medium-Level Problem Breakdown | Session Token Design + String Manipulation

Recently, big tech OAs have clearly entered peak season. Companies like Google, TikTok, and Amazon are rolling out assessments back-to-back. I just completed this Microsoft OA set — overall difficulty felt medium to upper-medium. It’s not template-based, but also not trick-heavy. The core evaluation focuses on data structure fundamentals and implementation stability under time pressure.


Q1: Maximum String Operations (String Manipulation)

Problem Summary

You can choose three consecutive characters s[i], s[i+1], s[i+2]. If the first two characters are equal and the third character is different, you may change the third character to match the first two. Return the maximum number of operations possible.

Core Insight

The key idea is propagation. Once a contiguous block of identical characters has length ≥ 2, it can spread to the right and convert different characters one by one.

Optimal Strategy (O(n))

  • Traverse from left to right.
  • Track the current consecutive identical character length.
  • If the streak ≥ 2 and the next character differs, count one operation and extend the streak.
  • No need to actually modify the string.

You only need to count how many characters can be absorbed by a valid streak. If string length < 3, return 0.


Q2: Session Authentication System (Token Design)

Problem Summary

Design a token authentication system with expiration rules. Each token has expiration time = current_time + TTL.

  • generate(token_id, current_time)
  • renew(token_id, current_time)
  • count(current_time)

Before any operation, expired tokens must be removed. If expire_time ≤ current_time, it is considered expired. Expired tokens cannot be renewed and must not be counted.

Clean Design

Use a HashMap:

token_id → expire_time

Operation Logic

Cleanup Step (Before Every Operation)

Remove tokens where expire_time ≤ current_time

generate

expire_time = current_time + TTL
store in hashmap

renew

If token exists and not expired, update expire_time

count

Cleanup first
Return hashmap size

Common mistake: using < instead of ≤ in expiration check. Also avoid overengineering with heaps or ordered sets. HashMap is sufficient for OA scope.


Practical Advice for Big Tech OA Preparation

Across Microsoft, Google, TikTok, and Amazon, the trend is clear: it’s not about just solving — it’s about stable AC under pressure.

  • Master boundary conditions (index bounds, expiration edges, empty inputs)
  • Train under time constraints (target: 2 problems AC within 30 minutes)
  • Keep code structure clean and readable
  • Think before coding — avoid brute-force traps

Many candidates don’t fail due to lack of ability. They lose points due to unstable execution under real exam pressure.


Need Practical Support?

If you're preparing for Microsoft, Google, TikTok, or Amazon OAs and:

  • Want recent real problem patterns
  • Need high-intensity timed simulations
  • Keep getting stuck on string/design/DP/graph problems
  • Want structured strategy guidance

You can reach out for practical interview assistance to improve both your problem-solving rhythm and pass rate.

Stability wins OAs.

Top comments (0)