Microsoft logo

Microsoft Software Engineer Coding Questions

45 practice questions for Microsoft Software Engineer interviews

Microsoft software engineer interviews cover algorithms, data structures, system design, and coding problems drawn from real interview rounds.

All Roles Software Engineer Backend Engineer Frontend Engineer Full Stack Engineer Mobile Engineer Data Engineer Data Scientist ML Engineer DevOps Engineer DevOps Engineer Product Manager SRE Security Engineer Engineering Manager Data Analyst UX/UI Designer QA Engineer
coding Medium Verified Question #1

1. Design Rate Limiter


Category: Sliding window coding problem
# Design Rate Limiter Design a rate limiter system that controls the number of requests allowed within a specified time window. The rate limiter is...
Input: String
Output: Computed result
coding Medium Verified Question #2

2. Object Oriented Design - Idempotent Receipt Sending


Category: Trie-based coding problem
Input: String
Output: Computed result
coding Medium Verified Question #3

3. Object Oriented Design - Notification Service


Category: Trie-based coding problem
# Problem Statement Design a notification service that supports sending notifications through multiple channels (SMS, Email) and is architected to...
Input: Number(s)
Output: Computed result
coding Medium Verified Question #4

4. Shortest Substring with N Unique Characters


Category: String coding problem
# Shortest Substring with N Unique Characters *This is a variation of the leetcode problem* Given a string s and an integer n, find the length of...
Input: String
Output: Computed result
coding Hard Verified Question #5

5. Rate Limiter


Category: Sliding window coding problem
Design a rate limiter that tracks API requests per client and enforces limits using a sliding time window. Your system must support: - hit(key,...
Input: Given input
Output:** Computed result
coding Hard Verified Question #6

6. Non-Adjacent Team Selection


Category: Tree coding problem
# Question You are given n people labeled from 0 to n - 1. Some pairs of people know each other directly. These relationships are given as a...
Input: List
Output: Computed result
coding Medium Verified Question #7

7. Bounded Repeat Substring


Category: String coding problem
A sensor data stream is represented as a string of characters. A contiguous segment of the stream is considered valid if it contains no three...
Input: String
Output: Computed result
coding Medium Verified Question #8

8. OA [CodeSignal] Prime Jumps


Category: Algorithm coding problem
# OA [CodeSignal] Prime Jumps A game is played with the following rules: - A player starts at cell 0 with a score of 0. - There is a row of n cells...
Input: Number(s)
Output: Computed result
coding Hard Verified Question #9

9. Combine N-ary Trees


Category: Tree coding problem
You are given the roots of two N-ary organization charts, each representing a hierarchical department structure. Every node has an integer...
Input: List
Output: Computed result
coding Medium Verified Question #10

10. Digit Replacement Maximizer


Category: String coding problem
A numeric optimization system performs exactly k substitution operations on a number string s. In each operation, choose any digit in s that is...
Input: String
Output: Computed result
coding Medium Verified Question #11

11. Best Window For Target Count


Category: Trie-based coding problem
A log analysis tool searches for the most frequent occurrence of a specific error code within a fixed-size window of log entries. Given an integer...
Input: Array
Output: Integer
coding Medium Verified Question #12

12. Evens Before Odds


Category: Array coding problem
You are given an integer array nums. Rearrange nums so that all even numbers appear before all odd numbers. The relative order of even or odd...
Input: Array
Output: Integer
coding Hard dynamic programming #1

1. [OA] Dynamic Programming — maximum subarray sum for data throughput optimization

In services like Azure Data Lake, it is important to find the maximum throughput of data streams over given segments. This requires identifying the largest sum of neighboring data packets for optimization.
Problem statement: Given an integer array nums, implement a function maxSubArray(nums: List[int]) -> int that returns the largest sum of contiguous elements in the array.
- Method Signature: def maxSubArray(nums: List[int]) -> int: Returns the maximum sum of a contiguous subarray.
Example 1:
Input: nums = [-2,1,-3,4,-1,2,1,-5,4]
Output: 6
Explanation: The contiguous subarray [4,-1,2,1] has the largest sum 6.
Example 2:
Input: nums = [1]
Output: 1
Constraints:
- 1 <= nums.length <= 10^5
- -10^4 <= nums[i] <= 10^4
coding Hard graph #2

2. [OA] Dijkstra's Algorithm — finding the shortest path in the Azure Network

Microsoft Azure needs to optimize routing between data centers. The goal is to find the shortest path between nodes in the network to enhance performance and reduce latency.
Problem statement: Given a directed graph represented as an adjacency list, implement a function dijkstra(graph: Dict[int, List[Tuple[int, int]]], start: int) -> Dict[int, int] that calculates the shortest path from a starting node to all other nodes.
- Method Signature: def dijkstra(graph: Dict[int, List[Tuple[int, int]]], start: int) -> Dict[int, int]: Returns a dictionary where keys are node indices and values are the shortest distances from the start.
Example 1:
Input: graph = {0: [(1, 4), (2, 1)], 1: [(3, 1)], 2: [(1, 2), (3, 5)], 3: []}, start = 0
Output: {0: 0, 1: 3, 2: 1, 3: 4}
Explanation: The shortest path from node 0 to node 3 is through 2 and then to 1.
Example 2:
Input: graph = {0: [(1, 2)], 1: [(2, 3)], 2: [(3, 1)], 3: []}, start = 0
Output: {0: 0, 1: 2, 2: 5, 3: 6}
Constraints:
- 1 <= len(graph) <= 10^4
- 0 <= graph[i][j][0] < len(graph)
- 0 < graph[i][j][1] <= 10^3

Related Microsoft Software Engineer interview prep

Start practicing Microsoft questions

Sign up for free to access walkthroughs, AI-generated questions, and more.

Get Started Free