microsoft logo
Microsoft· SDE II

Microsoft Recent SDE2 DSA Queations

Posted
26 Aug 2025
515 reads

Summary

I've compiled a set of Data Structures and Algorithms questions that were recently posed in SDE2 interviews at Microsoft, shared by myself and my friends.

How it went

This post is a collection of Data Structures & Algorithms questions that I and a few of my friends encountered during our recent SDE2 interviews at Microsoft. Our aim is to provide valuable insights into the types of problems asked for this role, ranging from standard LeetCode problems to custom algorithmic challenges and even a system design question. These questions were gathered from various rounds we faced, including some with direct LeetCode links and others described in detail. Hopefully, this comprehensive list will aid others preparing for similar roles.

Questions asked (16)

  1. 01

    Minimize String Partitions

    Data Structures & Algorithms

    You are given a string s = "31415926535 8979323846264338327" and a list of words: ["314", "15926535 89", "79323846264", "338327", "7932", "3846264", "338327"]. Your task is to partition the string s into substrings such that:

    • Each substring is present in the given list of words.
    • The number of partitions (substrings) is minimized.

  2. 02

    Time Based Key-Value Store

    Data Structures & Algorithms · Medium

    Design a time-based key-value store that supports set and get operations. The set operation stores a key with a value and a timestamp. The get operation retrieves the value associated with a key at a specific timestamp, returning the most recent value if multiple exist before or at the given timestamp.

    Open the problem
  3. 03

    Determine if Two Strings Are Close with Word Ladder Follow-up

    Data Structures & Algorithms · Medium

    Determine if two strings are 'close' based on specific operations (swap any two existing characters, or transform every occurrence of one existing character into another existing character, and vice versa). A follow-up problem, similar to 'Word Ladder', was also discussed.

    Open the problem
  4. 04

    Remove K Digits

    Data Structures & Algorithms · Medium

    Given a non-negative integer num represented as a string, remove k digits from the number so that the new number is the smallest possible. The length of num is less than 10002 and will be >= k.

    Open the problem
  5. 05

    Spiral Matrix

    Data Structures & Algorithms · Medium

    Given an m x n matrix, return all elements of the matrix in spiral order.

    Open the problem
  6. 06

    Design Text Editor with Undo/Redo

    System Design

    Design a text editor that supports basic operations like typing, deleting, and cursor movement, along with undo and redo functionalities. Several follow-up questions were also part of this problem.

  7. 07

    3Sum

    Data Structures & Algorithms · Medium

    Given an integer array nums, return all the triplets [nums[i], nums[j], nums[k]] such that i != j, i != k, and j != k, and nums[i] + nums[j] + nums[k] == 0. Notice that the solution set must not contain duplicate triplets.

    Open the problem
  8. 08

    Subarray Sum Equals K

    Data Structures & Algorithms · Medium

    Given an array of integers nums and an integer k, return the total number of contiguous subarrays whose sum equals to k.

    Open the problem
  9. 09

    Group Anagrams

    Data Structures & Algorithms · Medium

    Given an array of strings strs, group the anagrams together. You can return the answer in any order. An Anagram is a word or phrase formed by rearranging the letters of a different word or phrase, typically using all the original letters exactly once.

    Open the problem
  10. 10

    Find All Peak Elements in Array

    Data Structures & Algorithms · Medium

    Given an integer array nums, find all the peak elements. A peak element is an element that is strictly greater than its neighbors. If there are multiple peaks, return all of them.

    Open the problem
  11. 11

    Valid Parentheses

    Data Structures & Algorithms · Easy

    Given a string s containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid. An input string is valid if: Open brackets must be closed by the same type of brackets. Open brackets must be closed in the correct order. Every close bracket has a corresponding open bracket of the same type.

    Open the problem
  12. 12

    Sort Array by Set Bit Count

    Data Structures & Algorithms

    Given an integer array, sort the integers in ascending order based on the count of their set bits (1s in binary representation). If two numbers have the same count of set bits, maintain their relative order as in the original array (or sort by value if not specified, but typically stability is preferred).

  13. 13

    Remove Spaces from Character Vector In-place

    Data Structures & Algorithms

    Given a mutable sequence of characters (e.g., std::vector<char> or a character array), remove all spaces from it in-place. The relative order of non-space characters must be preserved.

  14. 14

    Delete Node in a Linked List

    Data Structures & Algorithms · Easy

    Write a function to delete a node (except the tail) in a singly linked list, given only access to that node. The given node will not be the tail and it will always be a valid node of the linked list.

    Open the problem
  15. 15

    Reconstruct Itinerary

    Data Structures & Algorithms · Hard

    You are given a list of airline tickets where tickets[i] = [fromi, toi] represent the departure and arrival airports of one flight. Reconstruct the itinerary in order. All of the tickets belong to a man who departs from 'JFK'. Thus, the itinerary must begin with 'JFK'. If there are multiple valid itineraries, you should return the itinerary that has the smallest lexical order when read as a single string. For example, the itinerary ["JFK", "LGA"] has a smaller lexical order than ["JFK", "LGB"]. All airports are represented by three uppercase English letters. You may assume that there exists at least one valid itinerary.

    Open the problem
  16. 16

    Maximum Profit of Contiguous Subarray (Length at most K)

    Data Structures & Algorithms

    You are given an integer array pnl of length n, where pnl[i] represents the profit or loss on day i. You are also given an integer k. Your task is to find the maximum possible profit of any contiguous subarray whose length is at most k.

Know someone preparing? Send it to them:WhatsAppLinkedInX

Interviewed at Microsoft recently?

Write up your rounds while you still remember the questions. It helps the next person more than you would think.

Share your experience
Discussion 0

Questions for the author, or how your own interview compared.

Join the discussion

Sign in with Google to comment or ask the author a question.

No comments yet

Be the first to share your thoughts and start the discussion!