Interview Questions148 real reports analyzed

Microsoft Interview Questions

The questions Microsoft actually asks — distilled from 148 real candidate reports and ranked by how often they came up. Coding, system design, and behavioral, with model answers written by our team.

76

questions tracked

45

coding problems

148

reports analyzed

Updated 2026-05-26

Most-asked Microsoft questions

The questions reported most often across real Microsoft interviews, each with a model answer written by our team.

Implement a Least Recently Used cache supporting get and put operations.

asked in 16 reportsmediumO(1) time for get/put, O(capacity) space

Use a HashMap + doubly linked list. The map stores key→node pointers for O(1) lookup. The linked list maintains LRU order: most recent at head, least recent at tail. On get(), move the accessed node to head. On put(), insert a new node at head; if capacity is exceeded, evict the tail. The key insight: HashMap enables O(1) key access while bidirectional pointers allow O(1) node removal and insertion without traversal.

Design a rate limiting system.

asked in 9 reportsmedium

Implement token bucket algorithm: each user/IP has a bucket refilling at a fixed rate. Store bucket state (tokens, last_refill_time) in Redis for distributed access. On request, decrement tokens if available; reject if depleted. Key components: configurable rate limits per dimension (user/IP/endpoint), distributed Redis store with consistent hashing for scale, monitoring/alerting. Support burst capacity for traffic spikes. Critical insight: token bucket elegantly handles both steady traffic and bursts—unlike sliding windows (high memory) or fixed windows (creates traffic clumping).

Find the longest substring without repeating characters in a given string.

asked in 6 reportsmediumO(n) time, O(min(m, n)) space

Use a sliding window with a hash map storing each character's last-seen index. Expand the right pointer; when you encounter a duplicate, move the left pointer to just after that character's previous occurrence. Track the maximum window size throughout. The key insight: the left pointer never moves backward. Once a duplicate is resolved, you've already processed those characters—no need to revisit them. This guarantees a single pass through the string.

Describe something you are proud of.

asked in 5 reports

I led a data pipeline architecture redesign that reduced query latency by 60% and cut infrastructure costs by $2M annually. I identified the bottleneck, aligned three teams on the solution, and owned the implementation end-to-end. What I'm most proud of isn't just the technical outcome—it's that the system now scales to serve 10x more customers without degradation. The experience reinforced that great engineering anticipates future needs, not just solves today's problems.

Design a parking lot system with support for multiple vehicle types and dynamic space conversion.

asked in 5 reportshardReservation: O(n) worst-case linear search; Conversion: O(n log n) space adjacency scanning; Space lookup: O(1) via hash map by type.

Model Vehicle and ParkingSpace as abstract classes with concrete implementations (Car, Truck, Motorcycle). Each space tracks size requirements using an enum (COMPACT, LARGE, HANDICAP). The core insight: implement a SpaceConverter service monitoring occupancy rates. When large spaces exceed threshold availability, algorithmically combine adjacent compact spaces; conversely, split underutilized large spaces into compacts. Use a LotManager coordinating reservations against available capacity per type. Dynamic conversion happens asynchronously, rebalancing inventory based on real-time demand patterns. This avoids static overallocation while maintaining SLA compliance.

Design a URL shortening service.

asked in 5 reportsmedium

Use a stateless service layer with separate encode/decode APIs. For code generation, counter-based approach (auto-increment with base62 encoding) avoids collisions and scales linearly. Store URL mappings in replicated SQL database, indexed by short code. Deploy Redis cache for 80/20 hot-URL reads. Shard database by hash(short_code) or user_id range for horizontal scale-out. Each URL has TTL for cleanup. Key insight: counter-based generation is simpler and more reliable than hashing in distributed settings. For Microsoft, emphasize consistency guarantees, handling storage failures, and observability.

Solve a graph problem at medium difficulty.

asked in 5 reportsO(m × n) time and space

Apply DFS or BFS to find connected components. Iterate through each grid cell; when you encounter an unvisited land cell ('1'), increment the island count and traverse all adjacent land cells to mark them visited. The key insight is that each connected component of '1's represents one island. This transforms the problem into standard graph traversal with implicit edges between adjacent cells.

Design a distributed cache system.

asked in 4 reportshard

Use consistent hashing to distribute data across nodes, enabling horizontal scaling and minimizing rehashing on node changes. Implement multi-level replication (primary + replicas) for fault tolerance; read from replicas, write to primary with async propagation. Layer LRU/LFU eviction policies per node to manage memory. Include heartbeat-based health checks and automatic failover. Use write-through or write-back strategies depending on durability needs. Add monitoring for cache hits/misses and node latency. For hot keys, implement local caching at client tier. Consider eventual consistency vs strong consistency based on use case.

Given meetings with start and end times, identify all overlapping pairs.

asked in 4 reportsmediumO(n²) time, O(n) space

Sort meetings by start time. For each meeting, compare against all previous ones to detect overlaps (two meetings overlap if meeting₁.start < meeting₂.end AND meeting₂.start < meeting₁.end; with sorting, just check if current.start < previous.end). Collect all overlapping pairs. Optimize with an interval tree or sweep line for O(n log n + k) complexity. The key insight: sorting reduces pairwise checks to linear scans through candidates that could actually overlap.

Merge k sorted lists into a single sorted list.

asked in 4 reportshardO(N log k) time, O(k) space

Use a min-heap to track the head of each list. Extract the smallest element, add it to the result, and push the next element from that list back onto the heap. Repeat until all lists are exhausted. The heap maintains only k elements, making each operation O(log k). This outperforms merging pairwise (which repeats work on merged sublists) and beats sorting all elements. The key insight: the bottleneck is finding the minimum among k candidates—a heap solves this efficiently per extraction.

Determine the number of vehicle fleets that will reach a destination given their speeds and starting positions.

asked in 3 reportsmediumO(n log n) time, O(n) space

Calculate each vehicle's time to reach the destination: (target - position) / speed. Sort vehicles by position descending (closest to destination first). Iterate through sorted vehicles, counting a new fleet whenever a vehicle's travel time exceeds the previous vehicle's. A vehicle with longer travel time cannot catch the one ahead, forming a new fleet; shorter travel time means it catches up and joins an existing fleet. Return the fleet count.

Calculate the number of ways to decode a string where digits can represent letters.

asked in 3 reportsmediumO(n) time, O(1) space

Use dynamic programming tracking ways to decode up to each position. At each digit, check if it alone (1–9) or combined with the previous digit (10–26) forms a valid code. dp[i] = (s[i] != '0' ? dp[i-1] : 0) + (10 ≤ two_digit ≤ 26 ? dp[i-2] : 0). Optimize space by maintaining only the last two DP values instead of an array.

Explain your motivation for joining Microsoft.

asked in 3 reportseasy

Microsoft's reach across enterprise cloud, developer tools, and AI platforms attracted me. I'm motivated by working on technologies—Azure, ML platforms, Office—that solve real problems at scale. Your commitment to accessibility and responsible AI aligns with my engineering values. I'm also drawn to the learning culture where I can grow alongside world-class engineers while contributing to products used by billions. The opportunity to influence cloud infrastructure and AI direction, while mentoring others, is exactly where I want to invest my career.

Search for a target value in a rotated sorted array.

asked in 3 reportsmediumO(log n) time, O(1) space

Use binary search. Key insight: one half of a rotated sorted array is always properly sorted. Identify which half by comparing mid with boundaries, then check if the target falls within that sorted range. If so, search there; otherwise search the other half. This eliminates half the candidates per iteration without explicitly finding the rotation pivot.

Generate all valid combinations of balanced parentheses given n pairs.

asked in 3 reportsmediumO(4^n / n^1.5) time (nth Catalan number outputs), O(n) space

Use backtracking to build valid strings character by character. Maintain counts of opening and closing parentheses used. At each position, add an opening paren if we have remaining pairs, or a closing paren if it doesn't exceed the opening count. This constraint-based approach ensures all generated strings are valid without post-validation.

Describe a situation where you had a disagreement with a peer about a business matter.

asked in 3 reports

I disagreed with a teammate about feature prioritization: they wanted to ship early for competitive timing, while I advocated for technical debt paydown first. I listened to their market concerns, then presented data on our accruing maintenance costs. We jointly redefined scope—shipping the MVP on schedule but allocating a sprint for refactoring. This taught me business constraints matter; I learned to propose solutions, not just object. Microsoft values this: bringing contrasting perspectives, backing them with evidence, then collaborating to find a win-win that serves customers and business.