Contribute OA questions
OAHelper
CompaniesProblemsTopicsInterview Experiences
Explore
M

Microsoft

sde

Interview Date

14-08-2026

Result

Selected

Difficulty

Medium

Rounds

01

Drive Type

Off-Campus

Interview Date

14-08-2026

Result

Selected

Difficulty

Medium

Rounds

01

Drive Type

Off-Campus

Topics asked

dsa

Detailed experience

The interviewer opened with a custom data structure challenge: "Design a data structure supporting insert, remove, and getRandom in strict O(1) average time complexity." I pointed out that a hash table gives O(1) insertion and deletion but cannot select a random element uniformly in constant time because hash keys are sparse, while a dynamic array allows O(1) indexed random access but suffers O(N) removals when shifting elements. The interviewer followed up: "How do you achieve O(1) deletion in an array without leaving gaps or shifting elements?" I explained that we can combine a dynamic array with an unordered hash map storing value-to-index mappings: on removal, we swap the target element with the array's last element, update the moved element's index in the hash map, pop the tail in O(1) time, and erase the target key. He asked how `getRandom()` guarantees uniform distribution, so I showed how pulling `rand() % array.size()` over the compact array provides exact 1/N probability per item. I coded the complete class, handled the edge case where the element to delete is already the last element, and proved O(1) average time for all operations. He then transitioned to a bit-level tree problem: "Given an array of non-negative integers, find the maximum bitwise XOR value achievable by picking any pair of numbers nums[i] ^ nums[j]." I noted that checking all pairs takes O(N^2) time, which chokes when N approaches 10^5. I proposed building a Binary Trie (Bitwise Trie) where each number is inserted bit-by-bit from the most significant bit (bit 31 down to bit 0). The interviewer cut in: "Once the numbers are inserted, what is your greedy decision rule to maximize the XOR output?" I explained that for each number, we traverse the trie trying to greedily walk the opposite bit path (if current bit is 1, steer towards child 0, and vice versa) because differing bits produce a 1 at that power-of-two position. If the opposite branch does not exist, we fall back to the existing branch. He followed up: "Do you need two separate passes—one for building and one for querying?" I demonstrated that we can insert and query in a single combined pass, maintaining the running global maximum against previously seen numbers, bounding runtime to strict O(32 * N) = O(N) time and O(32 * N) = O(N) memory. For the final challenge, he introduced a classical matrix dynamic programming puzzle: "Given an m x n binary matrix filled with 0s and 1s, find the largest square containing only 1s and return its area." I dismissed the brute-force approach of evaluating every possible square's subgrid in O((M * N)^2) time and framed it using 2D Dynamic Programming. The interviewer followed up: "What is the recurrence relation, and why do you look at three neighboring cells instead of just the row and column lengths?" I explained that if `matrix[i][j] == '1'`, the maximum size of a valid square with its bottom-right corner at `(i, j)` is constrained by the weakest neighboring square: `dp[i][j] = min({dp[i - 1][j], dp[i][j - 1], dp[i - 1][j - 1]}) + 1`. If any of the top, left, or top-left cells represent a smaller square, a larger square at `(i, j)` cannot be formed without encompassing a 0. He challenged me on whether we could avoid allocating an O(M * N) auxiliary grid; I demonstrated rolling the state space into a single 1D array of length N plus a single `prev_diag` variable to track the overwritten top-left cell in-place. I wrote the code, dry-ran an edge case with a single '1' cell, and proved the O(M * N) time and O(N) space guarantee.

Posted on - 23 Sept 2026
Company OAsAll ProblemsTopicsCompany InsightsOA CalendarInterview ExperiencesPremium
OAHelper

Built by students, for students - practice company-specific OAs, DSA sheets, and real interview experiences to land your dream role.

© 2026 OAHelper.in·Terms·Privacy·Refunds·Trust & Safety·Contact·
Ready to crack your next OA?

Practice company-specific questions trusted by thousands of students across India.

Start PracticingGo Premium
OA Practice·DSA·Placements

Disclaimer: OAHelper is an independent educational platform. We (oahelper.in) do not own the images or questions shown. Content is uploaded by users.