Microsoft Interview Questions
Practice the exact questions companies are asking right now.
Validate a JSON-like string
Problem You are given a string s that is intended to be a JSON text. Implement a function isValidJsonStructure(s) -> bool that checks structural valid...
Rotate a 3×3 digit grid by 180°
Problem You are given a 3×3 grid of digits (characters '0'–'9'), represented as an array of 3 strings of length 3. When the entire grid is rotated by ...
Compare preference alignment methods for LLMs
Question You’re asked to discuss preference alignment approaches for large language models. Task Compare several alignment methods and explain when yo...
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...
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)...
Explain Transformers and deploy an LLM safely
Answer the following LLM-focused questions. 1) Transformer basics - What problem does the Transformer architecture solve compared with RNNs? - Explain...
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...
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...
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...
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...
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...
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...
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...
Behavioral & Leadership Fit at Microsoft
Microsoft Product Manager Onsite Interview – Behavioral & Leadership Context You are preparing for an onsite interview for a Product Manager role at M...
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...
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...
Cross-Team Conflict Resolution & Product Launch
Behavioral Question: Cross-Team Leadership, Conflict Resolution, and Course Correction Context: In a Product Manager HR screen, you may be asked to sh...
Implement a generic tree Node class
Design and implement a Node class for a mutable rooted tree. Requirements: store value, parent, and ordered children; support add_child, remove, move_...
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...
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) -> ...