Contribute OA questions
OAHelper
CompaniesProblemsTopicsInterview Experiences
Explore
M

Microsoft

sde

Interview Date

06-09-2026

Result

Rejected

Difficulty

Medium

Rounds

01

Drive Type

Off-Campus

Interview Date

06-09-2026

Result

Rejected

Difficulty

Medium

Rounds

01

Drive Type

Off-Campus

Topics asked

DSA

Detailed experience

The interviewer opened with an advanced divide-and-conquer dynamic programming scenario: "You are given an array of n items and need to partition them into k non-empty contiguous groups to minimize total cost, where cost(i, j) satisfies the Quadrangle Inequality (cost(a, c) + cost(b, d) <= cost(a, d) + cost(b, c) for all a <= b <= c <= d); compute the minimum cost in sub-quadratic time per layer." I pointed out that the standard recurrence dp[k][i] = min_{j < i} (dp[k - 1][j] + cost(j + 1, i)) takes O(k * n^2) naively. Because the cost function satisfies the Quadrangle Inequality, the optimal transition indices opt[k][i] exhibit monotonicity: opt[k][i] <= opt[k][i + 1]. The interviewer followed up: "Standard loops evaluate indices sequentially, so knowing opt[k][i] <= opt[k][i + 1] doesn't let you skip states in a simple linear pass—how does Divide and Conquer enforce this bound?" I explained that we compute the layer dp[k][L...R] using a recursive function `solve(L, R, opt_min, opt_max)`. At each step, we pick the midpoint M = (L + R) / 2 and compute dp[k][M] by testing all candidate split points j strictly within [opt_min, min(M - 1, opt_max)]. Once the optimal split point opt_M is found in O(opt_max - opt_min) time, the monotonic property guarantees that states in [L, M - 1] have optimal split points in [opt_min, opt_M], and states in [M + 1, R] have optimal split points in [opt_M, opt_max]. Splitting the search space recursively ensures that each depth level processes at most O(n) total candidates across its disjoint intervals. Across log n recursion levels, each layer is computed in O(n log n) time, dropping the total runtime to O(k * n log n) and O(n) space. He then shifted to a computational geometry and duality challenge: "Given n half-planes in a 2D plane, each defined by an inequality a_i * x + b_i * y + c_i <= 0, determine whether their common intersection region is non-empty, and if so, compute its convex polygonal boundary in O(n log n) time." I ruled out brute-force pairwise line intersection testing (which takes O(n^3)) and proposed Half-Plane Intersection via Polar Angle Sorting and a Monotonic Deque. The interviewer cut in: "Walk me through how sorting by polar angle simplifies edge tracking, and describe the exact conditions under which a half-plane is popped off the front or back of the deque." I explained that we represent each half-plane as a directed boundary vector (P, P + V) such that the valid region lies strictly to its left. We sort all half-planes by the polar angle of their directional vectors in [0, 2*pi). If two half-planes share identical angles, they are parallel; we retain only the innermost one and discard the other. We iterate through the sorted half-planes, maintaining active lines in a double-ended queue. When considering a candidate half-plane H, we look at the intersection point of the two most recent half-planes at the back of the deque; if this intersection point lies strictly outside H (on its right side, evaluated via a 2D cross-product turn test), that vertex is invalidated, so we pop the back of the deque. The identical check is performed against the front of the deque to account for circular boundary wrap-around. Once all lines are inserted, we pop redundant lines from the deque ends by cross-checking intersections with the opposite ends until all remaining adjacent line intersections lie within all half-planes. If the deque contains at least 3 lines, the intersection points of adjacent half-planes form the vertices of the convex kernel in clockwise order. He verified the cross-product orientation check and confirmed the O(n log n) sorting and O(n) sweep complexity. For the final challenge, he introduced an algebraic graph problem on spanning subgraphs: "Given an undirected unweighted graph with n vertices and m edges, determine whether the graph contains a simple cycle of length exactly k, where k is small (k <= 7), in time parameterized only by k and polynomial in n and m." I explained that standard DFS cannot easily locate fixed-length simple cycles because pruning revisited paths misses valid cycle completions, while exact backtracking runs in exponential O(n^k) time. I proposed the Color-Coding randomized technique. The interviewer challenged me: "Walk me through how assigning random colors to vertices isolates simple cycles from self-intersecting walks, and what is the exact probability of success per trial?" I explained that we assign each vertex one of k colors uniformly at random from {1, 2, ..., k}. A simple cycle of length k is called 'colorful' if all k vertices on the cycle receive distinct colors. Any walk that repeats a vertex cannot be colorful because the repeated vertex forces a duplicate color. By coloring vertices, detecting a colorful cycle reduces to Dynamic Programming over subsets: we define dp[v][mask] as whether there exists a simple path ending at vertex v whose visited vertices exhibit the exact color set represented by bitmask. The base case sets dp[v][1 << color[v]] = true for all v. For each step, we iterate through all edges (u, v) and masks, transitioning dp[v][mask | (1 << color[v])] = true whenever dp[u][mask] is true and (mask & (1 << color[v])) == 0. A cycle exists if any edge (u, v) connects two nodes with complementary masks covering all k bits. Because the probability that a specific k-cycle receives k distinct colors is k! / k^k (for k = 5, this is 120 / 3125 approx 0.0384), repeating the coloring trial e^k * ln(1 / delta) times guarantees finding the cycle with probability at least 1 - delta. Each trial takes O(m * 2^k) time using bitmask transitions, completely avoiding exponential dependence on the graph size n.

Posted on - 25 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.