Microsoft Software Engineer Interview Questions
Practice the exact questions companies are asking right now.
Solve binary-tree reverse printing and LPS
You are given a binary tree node definition: - TreeNode { int val; TreeNode left; TreeNode right; } Answer the following two algorithmic questions. 1)...
Design a cloud console main page
Scenario You are building the main landing page (home page) of a cloud service console that a user sees immediately after logging in (e.g., similar to...
Assemble DNA payload strings from tagged fragments
You are given a list of DNA-like fragments. Each fragment is a tuple: - start_tag: string - end_tag: string - payload: string A valid DNA chain is for...
Solve four classic algorithm problems
You are given four independent coding tasks. For each task, implement the required function. --- Problem 1: Zigzag level-order traversal of a binary t...
Implement a calendar with non-overlapping bookings
Problem Design a calendar booking system that stores half-open time intervals [start, end) (inclusive of start, exclusive of end). Implement a class w...
Find longest substring without repeating characters
Problem Given a string s, return the length of the longest contiguous substring that contains no repeated characters. Input - s: a string (may contain...
Find lowest common ancestor in tree
You are given the root of a binary search tree (BST) and two distinct nodes p and q that are guaranteed to exist in the tree. Task (BST case): - Find ...
Merge overlapping intervals
You are given an array of intervals, where each interval is represented as a pair of integers [start, end] with start <= end. The intervals may be uns...
Discuss proudest project and conflict handling
Answer the following behavioral questions in depth, demonstrating ownership and leadership: 1. Proudest project and ownership - Describe the projec...
Design local sports team recommendation system
Design a recommendation system that suggests local sports teams to users. High-level requirements: - Recommend sports teams that are relevant to a use...
Find max consecutive elements with sum below target
You are given: - An integer array nums of length n, sorted in non-decreasing order. - An integer index such that 0 ≤ index < n. - An integer target. S...
Count integer pairs satisfying 1/x + 1/y = 1/N
You are given a positive integer N (\(1 \le N \le 10^6\)). Consider the Diophantine equation: \[ \frac{1}{x} + \frac{1}{y} = \frac{1}{N}, \] where x a...
Find shortest substring with n unique letters
Problem You are given a string s consisting of lowercase English letters and an integer n (1 ≤ n ≤ 26). Find the length of the shortest contiguous sub...
Design top-K frequency store for varying workloads
Scenario You need to design an in-memory component that tracks how often each key appears in a stream of events. The component must support these oper...
Reverse linked list in fixed-size groups
Problem You are given the head of a singly linked list and an integer k (k >= 1). Reverse the nodes of the list in-place in groups of size k: - The no...
Merge multiple sorted arrays using min-heap
Problem You are given k sorted arrays of integers: - arrays[0], arrays[1], ..., arrays[k-1] - Each arrays[i] is sorted in non-decreasing order. - The ...
Solve three scheduling and array problems
In this round you are given three separate coding problems to solve. --- Problem 1: Schedule tasks with cooldown You are given: - A list of tasks, whe...
Discuss mutexes, memory alignment, polymorphism, idempotency
In this interview round, you are asked several conceptual software-engineering questions. Answer all parts clearly and concisely, using examples. --- ...
Implement a Tic-Tac-Toe game class
Problem Implement a class that supports playing an n × n Tic-Tac-Toe game. Requirements Create a class TicTacToe(n) with: - move(row, col, player) -> ...
Build a time-based key-value store
Problem Design a data structure that stores multiple values for the same key at different timestamps, and can retrieve the most recent value as of a g...