Microsoft Interview Experience | SDE 2 (62) [offer]

microsoft logo
microsoft
SDE 2Offer
August 8, 202117 reads

Summary

I successfully received an offer for the SDE 2 role at Microsoft after completing a comprehensive interview process that included online coding, project discussions, data structures and algorithms, system design, and a hiring manager round.

Full Experience

My interview process for the SDE 2 position at Microsoft was quite thorough, comprising five distinct rounds, and I'm pleased to share that I received an offer.

Round 0 - Online Codility round

This round was an online coding assessment. The questions were similar to those often discussed in LeetCode forums for Microsoft's OA.

Round 1 - Project Discussion and Problem Solving

This round began with a discussion of my past projects. Following that, I tackled two problem-solving questions:

First, I was asked to determine if two given strings were anagrams, with a strong emphasis on writing production-level code. Second, I faced a more complex challenge involving an array of positive integers that could have elements dynamically added or removed. The task was to find 'k' elements closest to a given number 'n'. The interviewer specifically required optimal performance for insert, remove, and search operations. I proposed and discussed a solution using a combination of a Binary Search Tree (BST) and a Heap.

Round 2 - Project Discussion + Design Round (HLD + LLD)

This round was a deep dive into system design, again starting with project discussions. The core problem was to design an API rate limiter. We extensively covered both fixed window and rolling window solutions, discussing their trade-offs in detail. I was expected to present both High-Level Design (HLD) and Low-Level Design (LLD), including appropriate class structures and interfaces. The interviewer also asked me to implement one specific method of the fixed window solution.

Round 3 - Project Discussion + Problem Solving

After another round of project discussions, I was given two more problem-solving tasks:

The first was to design a custom data structure that could support insert, delete, search, and getRandom operations, all in average constant time. A critical aspect of this problem was thread safety, leading to numerous questions about concurrency and synchronization, specifically how to allow a maximum of 'k' threads to access the getRandom method concurrently. The second problem involved a dictionary and a list of strings; I needed to list all matching anagrams of the input strings that existed in the dictionary. After exploring several approaches, I settled on an optimal solution using a Hashmap. My approach involved preprocessing the dictionary to store all anagrams against the sorted (lexicographically lowest) value of the string.

Round 4 - Hiring Manager (HM) Round

This final round with the Hiring Manager covered project discussions, system design, problem-solving, and some behavioral questions.

I was presented with a scenario involving 'n' files containing strings. The goal was to design a system that, given an input string, could list all files containing that string. I discussed preprocessing the files and solved the initial problem using a Trie, storing file paths within a BST at the end of the string to handle potential duplicate entries efficiently. The problem was then extended to consider additions, removals, and updates of files, which I addressed by incorporating versioning of file paths within the Trie and proposing a cron job for cleanup. We also discussed how to introduce authentication features into the search API.

Interview Questions (6)

Q1
Check if Two Strings are Anagrams
Data Structures & AlgorithmsEasy

Given two strings, determine if they are anagrams of each other. Production-level code quality was required.

Q2
Find K Closest Elements with Dynamic Array
Data Structures & AlgorithmsHard

Given an array of positive integers that supports dynamic addition and removal of elements, a number k, and a target number n, find k elements from the array that are closest to n. The data structure should support optimal insert, optimal removal, and optimal searching for k nearest elements. For example, if array is [10, 5, 30, 90, 101, 102, 115, 105], n = 100, k = 2 -> [101, 102]. If n = 100, k = 4 -> [90, 101, 102, 105].

Q3
Design API Rate Limiter
System DesignHard

Design an API rate limiter. We discussed both fixed window and rolling window solutions in detail, including their trade-offs. I was expected to provide both High-Level Design (HLD) and Low-Level Design (LLD), including class structure and interfaces. The interviewer also asked me to implement one method of a fixed window solution.

Q4
Design Data Structure with O(1) Insert, Delete, Search, GetRandom
Data Structures & AlgorithmsHard

Design a data structure that supports insert, delete, search, and getRandom operations, all in average constant time. Additionally, thread safety was a requirement, leading to discussions around concurrency and synchronization, specifically allowing a maximum of k threads to access the getRandom method.

Q5
Find Anagrams in a Dictionary
Data Structures & AlgorithmsMedium

Given a dictionary of words and a list of input strings, for each input string, return a list of all its anagrams that exist in the dictionary. We discussed several approaches, eventually focusing on an optimal solution. The dictionary was preprocessed to store all anagrams against the sorted representation (lowest value) of each string. For example, if dictionary has words abc, cab, def, random, domran, bac, the preprocessed HashMap would be {'abc': ['abc', 'cab', 'bac'], 'def': ['def'], 'admnor': ['random', 'domran']}. If input strings are [abc, fed, alpha], the output should be [['abc', 'cab', 'bac'], ['def'], []].

Q6
Search String in N Files with Dynamic Updates
System DesignHard

Given n files, each containing strings, and an input string, list all files that contain the given input string. The files can be preprocessed. The problem was extended to handle dynamic additions, removals, and updates of files. Further discussions included the introduction of authentication features for the search API.

Preparation Tips

My preparation focused on a few key areas. I always tried to treat the interviews as collaborative problem discussion sessions, ensuring I communicated my thought process clearly with the interviewers. For system design rounds, I made it a point to list and clarify all requirements upfront before diving into the solution architecture. I also strived to write clean, modular code, paying close attention to suitable class, method, and variable naming.

Discussion (0)

Share your thoughts and ask questions

Join the Discussion

Sign in with Google to share your thoughts and ask questions

No comments yet

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