← 返回博客列表
Microsoft

Microsoft OA Full AC Review: Alloy Production Binary Search + Max Team with Overlapping Intervals

2026-03-20

Microsoft OA — 75 minutes, 2 questions, full AC. T1 is a classic binary search on answer. T2 is an interval overlap counting problem. Pure logic breakdown below, no code.

Microsoft OA Problem Screenshot


Exam Overview

Item Details
Duration 75 minutes
Questions 2
Difficulty Medium
Role Intern / New Grad SDE
Result Full AC

T1: Maximum Alloy Production (Binary Search on Answer)

Microsoft OA T1 Alloy Production Problem

Problem Core

Given n types of metals, each with:

With a total budget, find the maximum number of alloy units that can be produced.

Approach

Key observation: as production quantity x increases, the total cost increases monotonically. This is exactly the condition for binary search on the answer.

Binary search framework:

check(x) logic:

  1. For each metal i, compute required amount: total = x * composition[i]
  2. If stock[i] >= total, no purchase needed
  3. Otherwise, buy (total - stock[i]) units at cost (total - stock[i]) * cost[i]
  4. Sum all purchase costs — return true if total cost <= budget

Result: the largest x for which check(x) returns true.

Complexity

Key Insight

Monotonicity is the prerequisite for binary search: more production always means more cost. The check(x) function is a single linear pass. Make sure the upper bound is large enough — use (budget / min_cost + max_stock) as a safe estimate to avoid truncating the answer.


T2: Maximum Team Size with Center Employee

Problem Core

Given each employee's work time interval [startTime[i], endTime[i]]. Two employees can interact if their intervals overlap.

Find the largest team such that one center employee overlaps with every other member. Return the maximum team size.

Approach

Equivalent restatement: find the employee i whose interval overlaps with the most other intervals (including themselves).

Overlap condition: intervals [s1, e1] and [s2, e2] overlap if and only if:

max(s1, s2) <= min(e1, e2)

Equivalently: s2 <= e1 AND e2 >= s1.

Brute force: enumerate every employee i as center, count overlapping employees — O(n²). Works for small inputs.

Optimized approach O(n log n):

  1. Sort all intervals by start
  2. For each interval i as center:
    • All intervals j with start[j] <= end[i] are candidates (binary search for right boundary)
    • Among those, exclude intervals where end[j] < start[i] (use a left pointer that advances as end[j] becomes too small)
  3. Valid count = right pointer - left pointer

Sweep line note: this problem is not asking for global maximum overlap at a point in time, but "how many intervals does a specific interval overlap with" — two-pointer on sorted intervals is more direct.

Complexity

Key Insight

"Center employee overlaps with everyone" = "find the interval that overlaps with the most other intervals". Sorting then two-pointer is the standard pattern for "how many intervals does interval i intersect".


Side-by-Side Comparison

Problem Core Technique Time Space
T1 Alloy Production Binary search on answer + linear check O(n log C) O(1)
T2 Max Team Sort + two-pointer interval overlap count O(n log n) O(n)

Common Pitfalls

Problem Pitfall Correct Direction
T1 Enumerating production quantity directly Recognize monotonicity, apply binary search
T1 Upper bound too small, answer gets truncated Estimate upper bound from budget and costs
T2 Using BFS / graph connectivity Not connectivity — need "one node covers all"
T2 Brute force O(n²) times out Sort + two-pointer brings it to O(n log n)

Microsoft OA Strategy

What to Expect

On-the-Day Tips

  1. "Maximum X satisfying constraint" type problems: check for monotonicity first — if monotone, binary search on answer
  2. Interval overlap/coverage problems: sort first, then consider two pointers or sweep line
  3. Set the binary search upper bound carefully to avoid truncating the answer
  4. The overlap condition max(s1,s2) <= min(e1,e2) is equivalent to two inequalities — memorize both forms
  5. Test edge cases: single employee, all overlapping, no overlapping

Related LeetCode Practice

# Problem Connection
2861 Maximum Number of Alloys T1: identical problem type
875 Koko Eating Bananas T1: binary search on answer classic
2779 Maximum Beauty of an Array T2: interval coverage counting
56 Merge Intervals T2: interval sorting

🚀 Need Microsoft OA Assistance?

oavoservice specializes in full-service OA/VO support for top North American tech companies. Microsoft OA is one of our core service areas with extremely high real question pool coverage.

Add WeChat now: Coding0201

You'll get:

📱 WeChat: Coding0201 | 💬 Telegram: @OAVOProxy | 📧 [email protected]