SDE
Interview Date
17-08-2026
Result
Rejected
Difficulty
Medium
Rounds
01
Drive Type
Off-Campus
Topics asked
Detailed experience
The interviewer opened with an advanced shortest-path query challenge on directed graphs with forbidden transitions: "Given a directed graph with n vertices and m edges where turning from edge (u, v) directly onto edge (v, w) is prohibited for a specified set of k forbidden subpaths, compute the shortest path from source s to destination t in polynomial time without exploding the search space." I explained that running standard Dijkstra on the original vertices fails because edge traversals violate Markovian independence—the validity of the next step depends on the preceding edge. I proposed constructing a Line Graph Dual Automaton. The interviewer followed up: "If forbidden sequences are paths of length greater than 2, transforming nodes into directed edges alone isn't enough; how do you handle arbitrary-length forbidden subpaths without exponential state branching?" I explained that we model the set of forbidden subpaths as a dictionary of forbidden words over edge identifiers and construct an Aho-Corasick Automaton on this dictionary. We then define an augmented state space where each state is a pair: `(current_directed_edge, aho_corasick_node)`. When stepping from directed edge e1 = (u, v) to e2 = (v, w), we feed the token e2 into the Aho-Corasick automaton to transition to a new matching state. If the resulting state matches any forbidden suffix pattern (detected via dictionary match links in O(1)), the transition is blocked. Otherwise, the step is valid and assigned the original weight of e2. Running Dijkstra over this product graph finds the optimal path in O((m + k) log(m + k)) time and O(m + k) space. He then shifted to an online computational geometry and extreme-point scenario: "Design a data structure that maintains an initially empty 2D dynamic convex hull under a continuous stream of point insertions, deletions, and arbitrary extreme-point queries (such as finding the point maximizing a linear dot product c_x * x + c_y * y) in polylogarithmic time per operation." I noted that Graham Scan or Monotone Chain requires full O(N log N) re-computation upon deletions, while standard dynamic hulls (like Overmars-van Leeuwen) are notoriously difficult to implement due to complex tree concatenations and bridge findings. I proposed Dual Transformation into Dynamic Half-Plane Maintenance via a Link-Cut Tree / Treap or an Overmars-van Leeuwen Hull with fractional cascading. The interviewer cut in: "Let's focus on the Overmars-van Leeuwen structure. Walk me through the bridge-finding invariant between left and right child hulls during a tree node update, and explain why finding the common tangent takes O(log^2 N) or O(log N) time." I broke down the divide-and-conquer tree layout: points are stored sorted by x-coordinate at the leaves of a balanced binary search tree. Each internal node represents the upper convex hull of its subtree, formed by finding the upper common tangent (bridge) between the hull of its left child and the hull of its right child. Finding this bridge corresponds to finding the mutual support lines: we perform a simultaneous binary search over the convex chains of both children. At each step, by comparing the slopes of child hull segments against the line connecting the candidate bridge endpoints, we determine whether each endpoint must move clockwise or counter-clockwise along its chain, halving the candidate segments of at least one child per step. This locates the bridge in O(log N) time. Storing only the bridge endpoints at each internal node avoids copying child hulls, enabling point insertions and deletions to update the tree along a single root-to-leaf path in O(log^2 N) time and O(N) space. For the final challenge, he introduced an algebraic combinatorial sequence reconstruction task: "Given the pairwise Manhattan distance matrix D between n unknown points located on a 1D line (where point coordinates are positive integers and D is an unordered multiset of n*(n-1)/2 distances), reconstruct the original coordinate set X = {x_1, x_2, ..., x_n} with x_1 = 0 in polynomial or efficient pruned-backtracking time." I identified this immediately as the Turnpike Reconstruction Problem (Partial Digest Problem). I pointed out that treating it as an unconstrained subset search checks 2^(n*(n-1)/2) combinations, which is completely intractable when n exceeds 20. I proposed a Pruned Branch-and-Bound Backtracking search over a maximum-priority multiset. The interviewer challenged me: "Walk me through how the largest remaining distance in the multiset deterministically limits the search space to at most two symmetric placements at each step, and what invariant prunes invalid branches." I explained that without loss of generality, we set the first point x_1 = 0. The largest distance in the multiset D must be the distance between x_1 and the farthest point x_n, so x_n = max(D). We remove max(D) from D and place x_n. At any intermediate step where a subset of points has already been committed, we inspect the current maximum remaining distance d = max(D). This distance d must be realized between an unplaced point and one of the two boundaries: either an unplaced point sits at position y = d (relative to 0), or at position y = x_n - d (relative to x_n). We branch on these two possibilities: for a candidate position y, we verify whether all pairwise distances {|y - p| : p in current_placed_points} exist in our multiset D. If any required distance is missing, candidate y is immediately pruned without recursion. If all distances exist, we remove them from D, add y to our placed set, and recurse. While worst-case instances exist with exponential bounds, bounding placements to the multiset extremes prunes non-realizable branches almost immediately, recovering the exact coordinates for practical n in O(n^2 log n) average time and O(n^2) space.