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 dynamic graph connectivity and biconnectivity problem: "Design a data structure for an undirected graph of n vertices that supports dynamic edge insertions, edge deletions, and online queries asking whether two arbitrary vertices u and v belong to the same 2-edge-connected component (share no bridge) in polylogarithmic amortized time per operation." I noted that Link-Cut Trees handle 1-connectivity (spanning trees) easily, but tracking 2-edge-connected components (bridge-blocks) under arbitrary deletions requires handling cycles and edge replacements without collapsing the whole tree. I proposed Thorup-Holm-de Lichtenberg-Scharp (HDT) Dynamic Biconnectivity. The interviewer followed up: "Walk me through how HDT stratifies non-tree edges into logarithmic levels, and how a tree edge deletion searches for a replacement non-tree edge to preserve 2-edge connectivity." I explained that edges are assigned hierarchical levels from 0 to L_max = floor(log_2 n), where a spanning forest is maintained at every level using an Euler Tour Tree (ETT) or Link-Cut Tree. All edges enter at level 0. When a tree edge e at level l is deleted, it disconnects a tree into two components, T_small and T_large. To determine if e was a bridge or if an alternate non-tree edge restores connectivity, the algorithm only inspects non-tree edges incident to T_small at level l. If an inspected edge connects two nodes inside T_small, it is promoted to level l + 1 (charging its inspection against its promotion budget). If an inspected edge crosses from T_small to T_large, it immediately replaces e as the new spanning tree edge at level l, preventing component separation. Because an edge can be promoted at most log n times before hitting L_max, finding replacement edges across levels amortizes to O(log^2 n) time per update, answering 2-edge-connected component queries via root identifiers in O(log n / log log n) time. He then shifted to string querying over arbitrary sub-interval factorizations: "Given a static string s of length n, answer q online queries asking for the Lyndon Factorization of an arbitrary substring s[L...R] in time strictly sub-linear with respect to the query substring length R - L + 1." I pointed out that running Duval's algorithm on the fly takes O(R - L + 1) per query, which degrades to O(q * n) in the worst case. I proposed precomputing a Lyndon Tree over the entire string paired with Binary Lifting and Range Minimum Queries (RMQ). The interviewer cut in: "A substring s[L...R] does not necessarily match an exact subtree of the global Lyndon Tree; how do you locate the right-to-left Lyndon factors of s[L...R] in logarithmic time per factor?" I explained that the Lyndon Tree of s is a binary tree where each node represents a Lyndon word formed by merging two adjacent Lyndon words u and v such that u < v lexicographically. In any substring s[L...R], its first Lyndon factor w_1 is the longest Lyndon prefix of s[L...R]. Using a Suffix Array with an LCP-array RMQ, comparing any two suffixes takes O(1) time. We can locate the longest Lyndon prefix starting at index L bounded by R by binary lifting over the Lyndon Tree: starting at the leaf corresponding to s[L], we ascend parent pointers as long as the right boundary of the node's interval does not exceed R and the prefix retains the Lyndon property. Once w_1 is identified in O(log n) time, we advance the search pointer to L' = L + |w_1| and repeat the process to find w_2, w_3, and so on. This extracts the entire Lyndon factorization of s[L...R] in O(k log n) time, where k is the number of factors in the factorization, completely bypassing full substring rescans. For the final challenge, he introduced an algebraic shortest-path problem on sparse metrics: "Given a directed graph with n vertices and integer edge weights bounded by W, compute all-pairs shortest paths (APSP) in strictly sub-cubic time without using classical Floyd-Warshall (O(n^3)) or running n independent Dijkstra passes." I noted that Floyd-Warshall operates in O(n^3), which TLEs when n reaches 2000. I proposed reducing APSP over the (min, +) tropical semiring to Fast Matrix Multiplication via Seidel's Algorithm or the Alon-Galil-Margalit (AGM) algebraic reduction. The interviewer challenged me: "Min-plus matrix multiplication has no known sub-cubic algorithm for arbitrary large weights. How does the AGM / Zwick algorithm use Strassen-like matrix multiplication over the standard ring to solve APSP when edge weights are small integers in {-1, 0, 1}?" I broke down the algebraic reduction: we construct a symbolic matrix where each edge (u, v) with weight w(u, v) is encoded as a polynomial monomial term (1 + r_{u,v}) * x^{w(u, v) + 1} over a truncated polynomial ring or finite field. When multiplying these distance matrices using standard Strassen or Coppersmith-Winograd fast matrix multiplication in O(n^omega) where omega < 2.372, the polynomial product automatically computes path lengths in the exponent: x^a * x^b = x^{a + b}. The smallest exponent with a non-zero coefficient in row i and column j of the product matrix corresponds exactly to the minimum path weight dist(i, j). To prevent polynomial degree explosion, the algorithm recursively scales path lengths in powers of (1 + epsilon), rounding intermediate distances and computing bounded-hop shortest paths. This evaluates all-pairs shortest paths in O(W * n^omega) time, which is strictly sub-cubic for small weight bounds.