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...
Explain KNN and how to tune it
K-Nearest Neighbors (KNN) fundamentals You are interviewing for a Data Scientist role. 1. Explain how the KNN algorithm works for both classification ...
Compute and plot a precision–recall curve
Precision–Recall (PR) curve coding / evaluation You are given a binary classifier’s outputs on a dataset: - y_true: array of true labels in \(\{0,1\}\...
Design a live-stream comments system
System Design: Live-stream comments (YouTube Live-style) Design a system that supports real-time comments for live video streams. Core features - User...
Calibrate LLM output to match Word formatting
Scenario You’re building an LLM-powered feature in a word processor (e.g., Microsoft Word) that generates content users can insert directly into a doc...
Group GPUs by node and partition by links
Problem: GPU graph grouping and link-maximizing partition You are given a cluster of GPUs represented as a graph: - Each GPU has a unique gpuId and be...
Implement a rate limiter at scale
Problem Design and implement a rate limiter that enforces request limits per key (e.g., per user ID or API key). Requirements - Implement allow(key, t...
Return a topological ordering of a graph
Problem: Output a topological ordering Given a directed graph with n nodes labeled 0..n-1 and a list of directed edges edges, return a topological ord...
Design REST APIs for JSON file storage
Scenario Design a service that stores JSON files/documents and exposes a RESTful API for clients. Requirements - Clients can upload, download, list, a...
Optimize vector semantic search for an assistant
Scenario You own the vector semantic search layer for an AI assistant (e.g., Copilot). Users query across enterprise documents and/or product knowledg...
Infer user intent from typing in real time
Scenario You’re building an AI feature that observes a user’s typing stream in an editor/search box and predicts the user’s intent in real time. This ...
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...
Design a resource change tracking database
Scenario You are building part of an Azure-like cloud control plane. Resources (VMs, networks, storage accounts, etc.) are stored as JSON documents an...
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 ...
Check palindrome number and next palindrome
Problem You are given a non-negative integer n. 1. Determine whether n is a palindrome in base-10 (it reads the same forward and backward). 2. Follow-...
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...
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)...
Compute distance of each node to a cycle
Problem You are given an undirected graph with n nodes labeled 0..n-1 and a list of edges. The graph is connected and contains exactly one simple cycl...
Design email ranking and summarization in Outlook
Scenario You are building ML features for an email client: 1) Debias email display order (inbox ranking) so users see the most relevant emails first w...
Design a RAG-based assistant service
Scenario You need to build a Retrieval-Augmented Generation (RAG) assistant for an enterprise product. It should answer questions using internal docum...