← Ziphq Interview Insights

Ziphq·Software Engineer·Technical Phone Screen·Senior

Senior
Jul 2026

Summary

ZipHQ software engineering interview with a two-part pathfinding problem. The first part was a classic BFS variant and the second layer added time-dependent moving obstacles, which made it significantly harder to reason about on the fly.

Questions Asked (2)

Q1

Given an infinite 2D grid with static blocked cells, find any shortest path from a start coordinate to a goal coordinate using BFS. Your solution must terminate even if the goal is unreachable.

Algorithms & Data Structures
Author's notes

The infinite grid part is what tripped me up initially.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Use BFS with a queue to explore the grid level by level, marking visited cells to avoid cycles. Since the grid is infinite, bound the search by the Manhattan distance from start to goal; if the goal is unreachable, BFS will exhaust all reachable cells within that bound and terminate.

Pro tip: Mention that you can optimize by using a bidirectional BFS or A* with Manhattan distance heuristic, but for an infinite grid, the key is to set a termination condition based on the maximum possible distance to the goal.

1. Clarify assumptions and constraints

Confirm that the grid is infinite, movements are 4-directional, and blocked cells are static. Discuss how to represent the grid (e.g., hash set for blocked cells) and visited set.

2. Choose BFS and define termination condition

Explain that BFS guarantees shortest path in unweighted graphs. For infinite grid, set a bound: if the queue is empty or the current distance exceeds Manhattan distance from start to goal, terminate and return no path.

3. Implement BFS with queue and visited set

Use a queue for BFS, a set for visited coordinates, and a parent map to reconstruct the path. For each cell, explore neighbors, skip blocked or visited cells, and enqueue valid ones.

4. Reconstruct and return the path

Once the goal is reached, backtrack using the parent map to build the path from start to goal. If the queue empties without reaching the goal, return that no path exists.

5. Analyze complexity and edge cases

Discuss time and space complexity in terms of the number of reachable cells within the bound. Mention edge cases: start equals goal, start or goal blocked, and unreachable goal.

Key Points to Mention

  • BFS guarantees shortest path in unweighted grids.
  • Use a visited set to avoid revisiting cells and infinite loops.
  • Termination condition: bound search by Manhattan distance from start to goal.
  • Represent blocked cells efficiently, e.g., with a hash set.
  • Reconstruct path using a parent map or by storing paths in the queue.
  • Consider bidirectional BFS or A* for optimization, but BFS is sufficient.

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.

Q2

Extend the pathfinding problem to handle moving obstacles (parades) that shift position every 2 seconds. You can move or wait each second. Find the minimum-time path, again on an infinite grid, or return unreachable.

Algorithms & Data StructuresTechnical Trade-offs
Author's notes

This one was rough.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Model the problem as a time-expanded graph where each state is (position, time mod 2) because obstacles shift every 2 seconds. Use BFS to find the shortest path in this graph, checking at each step whether the next position is safe at the next time. If the target is reached, return the time; if BFS exhausts all reachable states, return unreachable.

Pro tip: Mention that the state space is finite modulo the obstacle period, so BFS will terminate; also discuss how to handle large time values by noting that if a path exists, it will be found within a bounded number of steps due to the periodic nature.

1. Understand the problem and constraints

Clarify that obstacles move periodically every 2 seconds, and you can move or wait each second. The grid is infinite, so you need an efficient search that doesn't explore infinitely.

2. Define state representation

Represent each state as (x, y, t mod 2) because the obstacle configuration repeats every 2 seconds. This reduces the infinite time dimension to a finite set of states per position.

3. Build time-expanded graph and BFS

From each state, consider moving to adjacent cells or waiting. For each action, compute the next time and check if the destination cell is free of obstacles at that time. Use BFS to find the shortest path in terms of time.

4. Handle termination and unreachable cases

Since the state space is finite (positions modulo obstacle period), BFS will either find the target or exhaust all reachable states. If exhausted, return unreachable.

5. Analyze complexity and optimize

Discuss time and space complexity: O(V+E) where V is the number of reachable states. Consider optimizations like bidirectional BFS or A* if applicable, and note that the infinite grid is effectively bounded by the reachable area.

Key Points to Mention

  • Time-expanded graph with periodicity: state = (position, time mod 2)
  • BFS guarantees shortest path in unweighted graph (each move/wait costs 1 second)
  • Obstacle checking: precompute or compute on-the-fly whether a cell is blocked at a given time mod 2
  • Termination: finite state space ensures BFS terminates; if target not found, unreachable
  • Complexity: O(N) where N is number of reachable states, which is bounded by area of reachable region times 2
  • Edge cases: start or target may be blocked at certain times; waiting may be necessary

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.