Nuro interview questions & answers

13 real Nuro interview questions with full model answers — Coding. Drawn from the same verified bank ChannelPulse drills from (13 Nuro questions in total).

CodingMediumNuroSoftware Engineer

1. Evaluate Division (LeetCode)

Model answer

The task

Given equations that define ratios between variables, answer queries asking for a ratio between two variables. Return -1.0 when the ratio cannot be determined.

Key idea

Represent each equation as two directed graph edges: from a to b with weight a / b, and from b to a with the reciprocal weight. A path’s edge weights multiply to give the ratio between its endpoints.

Approach

  1. Build a weighted adjacency list from the equations.
  2. For each query, return -1.0 if either variable is unknown.
  3. Otherwise, use DFS to find a path between the variables, multiplying edge weights along the way.
  4. Track visited variables so cycles do not cause repeated exploration.
  5. If the variables are the same and known, the ratio is 1.0.
from collections import defaultdict
from typing import List

class Solution:
    def calcEquation(
        self,
        equations: List[List[str]],
        values: List[float],
        queries: List[List[str]]
    ) -> List[float]:
        graph = defaultdict(list)

        for (numerator, denominator), value in zip(equations, values):
            graph[numerator].append((denominator, value))
            graph[denominator].append((numerator, 1.0 / value))

        def find_ratio(start: str, target: str) -> float:
            if start not in graph or target not in graph:
                return -1.0
            if start == target:
                return 1.0

            stack = [(start, 1.0)]
            visited = {start}

            while stack:
                variable, product = stack.pop()

                for neighbor, edge_value in graph[variable]:
                    if neighbor in visited:
                        continue

                    next_product = product * edge_value
                    if neighbor == target:
                        return next_product

                    visited.add(neighbor)
                    stack.append((neighbor, next_product))

            return -1.0

        return [find_ratio(a, b) for a, b in queries]

Complexity:

  • Time: O(Q(V + E)), where each query may traverse the full graph.
  • Space: O(V + E) for the graph and the DFS state.

Common follow-ups

  • How can repeated queries be sped up? Use weighted union-find to answer each query in near-constant time after preprocessing.
  • How would you handle inconsistent equations? Detect conflicting ratios when connecting variables or revisiting an already-connected pair.
  • What if the graph is very large but queries are few? Keep DFS/BFS per query to avoid more elaborate preprocessing.
CodingMediumNuroSoftware Engineer

2. Minesweeper (LeetCode)

Model answer

The task

Update a Minesweeper board after a cell is clicked. A clicked mine ends the game; an empty cell reveals either its adjacent mine count or, when there are none, the connected empty area and its bordering counts.

Key idea

Use breadth-first search to reveal empty cells. Count neighboring mines before revealing each cell, and only expand from cells with no adjacent mines.

Approach

  1. If the clicked cell contains a mine, change it to X and return.
  2. Otherwise, start a queue with the clicked cell.
  3. For each queued unrevealed cell, count mines in its eight neighbors.
  4. Reveal the cell as a digit if the count is positive; otherwise reveal it as B and enqueue its unrevealed neighbors.
  5. Return the updated board.
from collections import deque
from typing import List

class Solution:
    def updateBoard(self, board: List[List[str]], click: List[int]) -> List[List[str]]:
        rows, cols = len(board), len(board[0])
        start_row, start_col = click

        if board[start_row][start_col] == "M":
            board[start_row][start_col] = "X"
            return board

        queue = deque([(start_row, start_col)])
        directions = [
            (-1, -1), (-1, 0), (-1, 1),
            (0, -1),           (0, 1),
            (1, -1),  (1, 0),  (1, 1),
        ]

        while queue:
            row, col = queue.popleft()

            # A cell may be queued by more than one neighboring blank.
            if board[row][col] != "E":
                continue

            neighbors = []
            mine_count = 0

            for dr, dc in directions:
                nr, nc = row + dr, col + dc
                if 0 <= nr < rows and 0 <= nc < cols:
                    neighbors.append((nr, nc))
                    if board[nr][nc] == "M":
                        mine_count += 1

            if mine_count:
                board[row][col] = str(mine_count)
            else:
                board[row][col] = "B"
                for nr, nc in neighbors:
                    if board[nr][nc] == "E":
                        queue.append((nr, nc))

        return board

Complexity:

  • Time: O(R × C), since each cell is revealed at most once.
  • Space: O(R × C) in the worst case for the BFS queue.

Common follow-ups

  • How would you avoid recursion depth issues? Use an iterative queue or stack, as above.
  • What if diagonal neighbors do not count? Check only the four orthogonal directions.
  • What if the board is too large for memory? Process it in regions or store only changed cells, depending on how the board is represented.
CodingMediumNuroSoftware Engineer

3. Interval List Intersections (LeetCode)

Model answer

The task

Given two lists of closed intervals, each sorted by start time and internally non-overlapping, return all intervals where an interval from one list overlaps an interval from the other.

Key idea

For the current pair, their overlap runs from the later start to the earlier end. Once the interval that ends first is exhausted, it cannot overlap any later interval in the other list, so advance that pointer.

Approach

  1. Start pointers at the beginning of both lists.
  2. For the current intervals, compute the later start and earlier end.
  3. If the overlap is nonempty, add it to the result.
  4. Advance the pointer for whichever interval ends first. If they end together, advance either one (this solution advances the first).
  5. Continue until one list is exhausted.
from typing import List

class Solution:
    def intervalIntersection(
        self,
        firstList: List[List[int]],
        secondList: List[List[int]]
    ) -> List[List[int]]:
        intersections = []
        i = j = 0

        while i < len(firstList) and j < len(secondList):
            first_start, first_end = firstList[i]
            second_start, second_end = secondList[j]

            # The overlap, if any, is bounded by the later start
            # and the earlier end.
            start = max(first_start, second_start)
            end = min(first_end, second_end)

            # Closed intervals also intersect when start == end.
            if start <= end:
                intersections.append([start, end])

            # The interval that ends first cannot overlap later
            # intervals from the other list.
            if first_end <= second_end:
                i += 1
            else:
                j += 1

        return intersections

Complexity:

  • Time: O(m + n), where m and n are the lengths of the lists; each pointer only moves forward.
  • Space: O(1) auxiliary space, excluding the output list.

Common follow-ups

  • How should endpoint-only contact be handled? For closed intervals, retain start <= end; for half-open intervals, the overlap test may need to be strict.
  • What if the lists are not sorted? Sort them first, then merge overlaps within each list before applying the two-pointer scan.
  • Can the result be streamed? Yes; emit each overlap as it is found instead of storing it, if the caller can consume results incrementally.
CodingMediumNuroSoftware Engineer

4. Asteroid Collision (LeetCode)

Model answer

The task

Given a sequence of signed asteroid sizes, simulate their movement and collisions. Return the asteroids that remain, in their original order.

Key idea

A collision can happen only when a right-moving asteroid is followed by a left-moving one. Keep surviving asteroids in a stack; resolve each possible collision with the stack’s most recent survivor.

Approach

  1. Start with an empty stack.
  2. Process asteroids from left to right.
  3. While the stack’s top moves right and the current asteroid moves left, compare their sizes.
  4. Remove the smaller asteroid; if they are equal, remove both. Stop resolving if the current asteroid is destroyed.
  5. Add the current asteroid if it survives, then return the stack.
from typing import List

class Solution:
    def asteroidCollision(self, asteroids: List[int]) -> List[int]:
        survivors: List[int] = []

        for asteroid in asteroids:
            alive = True

            # Only a right-moving survivor can collide with a left-moving one.
            while (
                alive
                and asteroid < 0
                and survivors
                and survivors[-1] > 0
            ):
                top = survivors[-1]

                if top < -asteroid:
                    # The top asteroid is smaller and is destroyed.
                    survivors.pop()
                elif top == -asteroid:
                    # Both asteroids are destroyed.
                    survivors.pop()
                    alive = False
                else:
                    # The current asteroid is smaller and is destroyed.
                    alive = False

            if alive:
                survivors.append(asteroid)

        return survivors

Complexity:

  • Time: O(n), since each asteroid is pushed and popped at most once.
  • Space: O(n) for the stack of surviving asteroids.

Common follow-ups

  • How would you handle zero-sized asteroids? Define their movement and collision behavior, then adjust the collision rules accordingly.
  • Can the result be computed in place? Yes, use the input list’s prefix as the stack, if modifying the input is allowed.
  • What if collisions occur in multiple dimensions? A single stack is no longer sufficient; the model needs spatial positions and directions.
CodingMediumNuroSoftware Engineer

5. Sparse Matrix Multiplication (LeetCode)

Model answer

The task

Multiply two compatible matrices and return their product. Since many entries are zero, avoid doing multiplication work for zero-valued entries.

Key idea

For each nonzero value in a row of the first matrix, combine it only with nonzero values in the corresponding row of the second matrix. Pre-indexing the second matrix’s nonzero entries makes those values quick to access.

Approach

  1. Record each row of the second matrix as (column, value) pairs for its nonzero entries.
  2. Create a zero-filled result matrix.
  3. For each nonzero A[i][k], visit the nonzero entries in row k of the second matrix.
  4. Accumulate each product into the matching result cell.
from typing import List

class Solution:
    def multiply(
        self, mat1: List[List[int]], mat2: List[List[int]]
    ) -> List[List[int]]:
        rows_a = len(mat1)
        cols_a = len(mat1[0])
        cols_b = len(mat2[0])

        # Store only nonzero entries, grouped by row.
        nonzero_rows_b = []
        for row in mat2:
            nonzero_rows_b.append(
                [(j, value) for j, value in enumerate(row) if value != 0]
            )

        result = [[0] * cols_b for _ in range(rows_a)]

        for i in range(rows_a):
            for k, value_a in enumerate(mat1[i]):
                if value_a == 0:
                    continue

                for j, value_b in nonzero_rows_b[k]:
                    result[i][j] += value_a * value_b

        return result

Complexity:

  • Time: O(mn + np + mp + Σ nnz(B[k])) over nonzero A[i][k]; scanning inputs, initializing the result, and combining matching nonzeros.
  • Space: O(np + mp) for the indexed nonzeros of the second matrix and the result.

Common follow-ups

  • What if the result is also expected to be sparse? Store accumulated nonzero result entries in a map instead of allocating a dense matrix.
  • How would you handle matrices too large for memory? Partition rows or blocks and multiply them incrementally.
  • What if the input matrices are already stored in a sparse format? Iterate their stored entries directly, skipping the indexing scan.
CodingMediumNuroSoftware Engineer

6. Subrectangle Queries (LeetCode)

Model answer

The task

Design a data structure that returns the current value at a matrix cell and applies updates that assign one value to every cell in a specified subrectangle.

Key idea

Store the original matrix and record each subrectangle update instead of immediately changing every affected cell. For a query, scan updates from newest to oldest; the first update covering the requested cell determines its value.

Approach

  1. Copy the matrix when constructing the data structure.
  2. Keep updates as rectangle bounds plus the assigned value.
  3. On an update, append one record.
  4. On a cell query, scan records in reverse chronological order.
  5. Return the first covering update’s value, or the original matrix value if none covers it.
class SubrectangleQueries:
    def __init__(self, rectangle: list[list[int]]):
        # Preserve the starting values independently of the caller's matrix.
        self.rectangle = [row[:] for row in rectangle]
        self.updates = []

    def updateSubrectangle(
        self,
        row1: int,
        col1: int,
        row2: int,
        col2: int,
        newValue: int,
    ) -> None:
        self.updates.append((row1, col1, row2, col2, newValue))

    def getValue(self, row: int, col: int) -> int:
        # The most recent covering update wins.
        for row1, col1, row2, col2, value in reversed(self.updates):
            if row1 <= row <= row2 and col1 <= col <= col2:
                return value

        return self.rectangle[row][col]

Complexity:

  • Time: Initialization is O(RC); each update is O(1), and each query is O(U), where U is the number of updates.
  • Space: O(RC + U) for the copied matrix and recorded updates.

Common follow-ups

  • How can queries be faster? Use a 2D range-assignment structure, trading simpler updates for more complex bookkeeping.
  • What if updates are rare and queries are frequent? Apply updates directly to the matrix; updates then cost time proportional to the subrectangle’s area, while queries are O(1).
  • How can the update log be bounded? Periodically apply all pending updates to the matrix and clear the log.
CodingMediumNuroSoftware Engineer

7. Dot Product of Two Sparse Vectors (LeetCode)

Model answer

The task

Create a sparse-vector representation that can compute the dot product of two vectors efficiently. Most entries may be zero, so avoid processing zero values during each query.

Key idea

Store only nonzero values, keyed by their indices. For a dot product, iterate over the smaller stored map and look up each index in the larger one; only shared indices contribute.

Approach

  1. On construction, scan the input vector and store each nonzero value with its index.
  2. In dotProduct, choose the smaller of the two maps to iterate over.
  3. For each stored index, multiply its value by the other vector’s value at that index, if present.
  4. Sum the products and return the result.
class SparseVector:
    def __init__(self, nums: list[int]):
        # Store only nonzero entries: index -> value.
        self.values = {
            index: value
            for index, value in enumerate(nums)
            if value != 0
        }

    def dotProduct(self, vec: "SparseVector") -> int:
        # Iterate over fewer entries and probe the other vector.
        smaller, larger = (
            (self.values, vec.values)
            if len(self.values) <= len(vec.values)
            else (vec.values, self.values)
        )

        total = 0
        for index, value in smaller.items():
            total += value * larger.get(index, 0)

        return total

Complexity:

  • Time: O(min(k1, k2)) per dot product, where k1 and k2 are the nonzero counts; hash lookups are expected O(1).
  • Space: O(k) per vector, where k is its number of nonzero entries.

Common follow-ups

  • What if the nonzero entries are stored as sorted index-value pairs? Use two pointers to match indices in O(k1 + k2) time.
  • What if one vector is dense? Iterate over the sparse vector and index directly into the dense one.
  • What if many dot products use the same vectors? Keep the sparse representation and reuse it; consider caching results for repeated vector pairs.
CodingMediumNuroSoftware Engineer

8. Target Sum (LeetCode)

Model answer

The task

Count the ways to assign a plus or minus sign to each number so their signed sum equals the target.

Key idea

Let P be the sum of numbers assigned a plus sign, and let S be the sum of all numbers. Then the minus-assigned numbers sum to S - P, so P = (S + target) / 2. The problem becomes counting subsets with that sum.

Approach

  1. Compute the total sum S.
  2. Return 0 if the target is out of range or S + target is odd.
  3. Set the subset-sum capacity to (S + target) // 2.
  4. Use 1D dynamic programming, where dp[s] counts subsets summing to s.
  5. Process each number in descending sum order so it is used at most once.
from typing import List

class Solution:
    def findTargetSumWays(self, nums: List[int], target: int) -> int:
        total = sum(nums)

        # A signed sum cannot exceed the total magnitude.
        if abs(target) > total:
            return 0

        combined = total + target
        if combined % 2 != 0:
            return 0

        capacity = combined // 2
        dp = [0] * (capacity + 1)
        dp[0] = 1

        for value in nums:
            # Descending order prevents reusing this value.
            # When value is zero, each count is correctly doubled.
            for current_sum in range(capacity, value - 1, -1):
                dp[current_sum] += dp[current_sum - value]

        return dp[capacity]

Complexity:

  • Time: O(nP), where n is the number of values and P = (S + target) / 2.
  • Space: O(P) for the subset-sum counts.

Common follow-ups

  • How would you return the actual sign assignments? Store predecessors or use backtracking with memoization.
  • What if the input can contain negative values? Use a map of reachable sums to counts instead of the subset-sum transformation.
  • How can you reduce the DP memory further? The 1D array is already the standard space-optimized form for this approach.
CodingMediumNuroSoftware Engineer

9. Random Pick with Weight (LeetCode)

Model answer

The task

Implement a picker that returns an index at random, with each index’s chance of being selected proportional to its weight.

Key idea

Build prefix sums of the weights. Draw a uniformly random integer from the total weight’s range, then binary-search for the first prefix sum greater than the draw.

Approach

  1. Store cumulative weight sums during initialization.
  2. Keep the total weight, which is the last cumulative sum.
  3. For each pick, draw an integer in [0, total).
  4. Use binary search to find the first cumulative sum greater than that integer.
  5. Return the corresponding index.
import random
from bisect import bisect_right
from typing import List

class Solution:
    def __init__(self, w: List[int]):
        # Each index owns a range of integer outcomes proportional to its weight.
        self.prefix = []
        total = 0

        for weight in w:
            total += weight
            self.prefix.append(total)

        self.total = total

    def pickIndex(self) -> int:
        # The target is uniformly chosen from [0, total).
        target = random.randrange(self.total)

        # Find the first prefix sum strictly greater than target.
        return bisect_right(self.prefix, target)

Complexity:

  • Time: O(n) to initialize; O(log n) per pick due to binary search.
  • Space: O(n) for the cumulative sums.

Common follow-ups

  • What if weights change between picks? Use a Fenwick tree to support weight updates and weighted selection in O(log n).
  • How would you handle very frequent picks? The current approach already provides O(log n) picks; an alias table can provide O(1) picks after O(n) preprocessing if weights are static.
  • What if some weights are zero? The prefix search naturally skips indices with zero weight, so they are never selected.
CodingMediumNuroSoftware Engineer

10. Remove Sub-Folders from the Filesystem (LeetCode)

Model answer

The task

Given a list of folder paths, remove every path that is nested beneath another path in the list. Return only the paths that are not subfolders of any other listed path.

Key idea

Sort paths lexicographically so a parent folder comes before its descendants. A path is a subfolder of a retained path only if it starts with that path followed by /; the separator prevents confusing paths such as /a and /ab.

Approach

  1. Sort the paths.
  2. Iterate through them in sorted order.
  3. Keep the first path.
  4. For each next path, compare it with the most recently kept path.
  5. Keep it only if it does not begin with that path plus /.
from typing import List

class Solution:
    def removeSubfolders(self, folder: List[str]) -> List[str]:
        # Sorting places each folder before its descendants.
        folder.sort()
        result = []

        for path in folder:
            if not result or not path.startswith(result[-1] + "/"):
                result.append(path)

        return result

Complexity:

  • Time: O(n log n + L), where sorting costs O(n log n) comparisons and L is the total number of path characters checked.
  • Space: O(n) for sorting and the returned list.

Common follow-ups

  • How would you handle paths with repeated or trailing separators? Normalize paths before sorting and checking.
  • How would you solve this with a trie? Insert path components and mark terminal folders; skip descendants of any terminal node.
  • What if the paths arrive as a stream? A single pass is not generally enough to identify all parents; sort externally or buffer and sort the paths.
CodingHardNuroSoftware Engineer

11. Shortest Path in a Grid with Obstacles Elimination (LeetCode)

Model answer

The task

Find the fewest moves from the top-left to the bottom-right of a grid, moving only between adjacent cells. A limited number of obstacles may be removed along the way; return -1 if no route is possible.

Key idea

Use breadth-first search over states that include both the current cell and the number of obstacle removals left. Reaching the same cell with different remaining budgets represents different possibilities, so each such state must be tracked separately.

Approach

  1. Handle the case where the Manhattan-shortest route can be taken even if every cell along it were blocked.
  2. Start BFS at (0, 0) with the full removal budget.
  3. For each move, subtract one from the budget if the next cell is an obstacle.
  4. Skip moves that exceed the budget or reach a state already visited.
  5. Return the distance upon reaching the bottom-right cell; return -1 if BFS runs out of states.
from collections import deque
from typing import List

class Solution:
    def shortestPath(self, grid: List[List[int]], k: int) -> int:
        rows, cols = len(grid), len(grid[0])

        # The Manhattan-shortest route has rows + cols - 2 moves.
        if k >= rows + cols - 2:
            return rows + cols - 2

        # Each state records row, column, remaining eliminations, and distance.
        queue = deque([(0, 0, k, 0)])
        visited = {(0, 0, k)}
        directions = ((1, 0), (-1, 0), (0, 1), (0, -1))

        while queue:
            row, col, remaining, distance = queue.popleft()

            if row == rows - 1 and col == cols - 1:
                return distance

            for dr, dc in directions:
                nr, nc = row + dr, col + dc
                if not (0 <= nr < rows and 0 <= nc < cols):
                    continue

                next_remaining = remaining - grid[nr][nc]
                state = (nr, nc, next_remaining)

                if next_remaining >= 0 and state not in visited:
                    visited.add(state)
                    queue.append((nr, nc, next_remaining, distance + 1))

        return -1

Complexity:

  • Time: O(mnk), since BFS may explore each cell with each possible remaining budget.
  • Space: O(mnk), for the visited states and BFS queue.

Common follow-ups

  • Can memory be reduced? Track the greatest remaining budget seen at each cell and prune states with no better budget.
  • What if moves have different costs? Use Dijkstra’s algorithm over cell-and-budget states.
  • How would you return the route itself? Store each discovered state’s predecessor and reconstruct the path at the destination.
CodingHardNuroSoftware Engineer

12. Maximum Number of Visible Points (LeetCode)

Model answer

The task

Given points on a plane, an observer’s location, and a viewing angle, find the largest number of points that fit inside a view of that angle. Points at the observer’s exact location are visible regardless of direction.

Key idea

Convert each other point to its polar angle from the observer, sort those angles, and find the largest circular interval no wider than the viewing angle. Duplicate the sorted angles with a full turn added so intervals crossing the zero-angle boundary are handled linearly.

Approach

  1. Count points at the observer’s location separately.
  2. Convert the remaining points’ directions to radians and sort them.
  3. Append a copy of each angle shifted by \(2\pi\).
  4. Use two pointers to find the largest window whose angular span fits the limit.
  5. Add the coincident-point count to that window’s size.
import math
from typing import List

class Solution:
    def visiblePoints(
        self,
        points: List[List[int]],
        angle: int,
        location: List[int]
    ) -> int:
        same_location = 0
        directions = []

        for x, y in points:
            dx = x - location[0]
            dy = y - location[1]

            if dx == 0 and dy == 0:
                same_location += 1
            else:
                directions.append(math.atan2(dy, dx))

        directions.sort()

        # Duplicate angles after adding one full turn to cover wraparound.
        count = len(directions)
        extended = directions + [a + 2 * math.pi for a in directions]
        limit = math.radians(angle)

        best = left = 0
        for right, current in enumerate(extended):
            while current - extended[left] > limit + 1e-12:
                left += 1
            best = max(best, right - left + 1)

        return same_location + best

Complexity:

  • Time: O(n log n), dominated by sorting the directions.
  • Space: O(n), for the angle list and its duplicated copy.

Common follow-ups

  • What if points may be duplicated? Each input point is counted separately, including duplicates at the observer’s location.
  • How would you handle many angle queries for the same points? Sort directions once, then use binary search or a sliding-window pass per query.
  • Why use a small tolerance in the comparison? Floating-point angle calculations can introduce tiny rounding errors at the boundary.
CodingHardNuroSoftware Engineer

13. Alien Dictionary (LeetCode)

Model answer

The task

Infer a character order consistent with a list of words already sorted in an unknown alphabet. Return one valid order, or an empty string if the list is inconsistent.

Key idea

For each adjacent pair of words, their first differing characters reveal a precedence rule. These rules form a directed graph; a topological sort produces a valid character order if and only if the graph has no cycle.

Approach

  1. Add every character to the graph, including characters with no ordering rules.
  2. Compare adjacent words and add an edge from the first differing character in the earlier word to the one in the later word.
  3. If the earlier word is a strict extension of the later word, return "" because that ordering is impossible.
  4. Use Kahn’s algorithm to process zero-indegree characters and build an order.
  5. If not all characters are processed, the rules contain a cycle; return "".
from collections import defaultdict, deque
from typing import List

class Solution:
    def alienOrder(self, words: List[str]) -> str:
        # Include characters that do not appear in any precedence rule.
        graph = {char: set() for word in words for char in word}
        indegree = {char: 0 for char in graph}

        # Adjacent words are enough to infer all necessary ordering rules.
        for first, second in zip(words, words[1:]):
            limit = min(len(first), len(second))

            for i in range(limit):
                if first[i] != second[i]:
                    before, after = first[i], second[i]
                    # Avoid counting duplicate rules more than once.
                    if after not in graph[before]:
                        graph[before].add(after)
                        indegree[after] += 1
                    break
            else:
                # A longer word cannot precede its own strict prefix.
                if len(first) > len(second):
                    return ""

        queue = deque(char for char in graph if indegree[char] == 0)
        order = []

        while queue:
            char = queue.popleft()
            order.append(char)

            for neighbor in graph[char]:
                indegree[neighbor] -= 1
                if indegree[neighbor] == 0:
                    queue.append(neighbor)

        # Unprocessed characters indicate a cycle.
        return "".join(order) if len(order) == len(graph) else ""

Complexity:

  • Time: O(C + V + E), where C is the total input length, V the number of distinct characters, and E the number of inferred rules.
  • Space: O(V + E) for the graph, indegrees, and queue.

Common follow-ups

  • How can you tell whether the ordering is unique? Check whether the queue ever contains more than one character.
  • What if there are multiple valid orders? Any topological ordering is acceptable; changing the queue policy can choose a different one.
  • Can you return a cycle when the input is inconsistent? Track DFS parents or predecessor links during topological processing to reconstruct one.

Practice these out loud, don't memorise them

Reading an answer is not the same as being able to give one under pressure. ChannelPulse plays the interviewer, asks the follow-ups, and scores each answer with feedback and a model answer so you can hear the gap between what you said and what lands.

Get ChannelPulse Browse all questions