← Uber Interview Insights

Uber·Software Engineer·Online Assessment (OA)·Intermediate

Intermediate
May 2026

Summary

Uber coding round, part of their Hack2Hire process. Just one problem but it was enough to keep me busy.

Questions Asked (1)

Q1

Given a grid of characters, determine whether a target word exists as a sequence of adjacent cells along a single straight line (horizontal, vertical, or diagonal).

Algorithms & Data Structures
Author's notes

Spent the first few minutes overcomplicating it.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Clarify that the word must be contiguous along a single straight line, then iterate over each cell and each of the 8 directions, checking if the word can be formed. Use early termination and boundary checks to keep the solution efficient.

Pro tip: Mention that you can prune directions early by checking the first and last characters of the word against the grid boundaries, and discuss how this approach scales for multiple word queries.

1. Clarify constraints and assumptions

Confirm that the word must be contiguous, can go in any of the 8 directions, and that cells cannot be reused. Ask about grid size, character set, and whether multiple queries are expected.

2. Define directions and boundary checks

List the 8 direction vectors (dx, dy) and write a helper to check if a cell is within bounds. This avoids repeated boundary logic.

3. Iterate over starting cells

For each cell that matches the first character of the word, try each direction. For each direction, walk step by step and compare characters until the word is exhausted or a mismatch occurs.

4. Optimize with early termination

Before walking, check if the word can fit in that direction from the starting cell (e.g., ensure enough remaining cells). Also, if the word length is 1, handle it separately.

5. Analyze complexity and edge cases

State time complexity O(N*M*8*L) where L is word length, and space O(1). Discuss edge cases: empty grid, word longer than grid dimensions, single-character word, and repeated characters.

Key Points to Mention

  • The 8 possible directions: horizontal, vertical, and both diagonals.
  • Boundary checking to avoid index out of bounds.
  • Early termination when the remaining cells in a direction are fewer than the remaining characters.
  • Time complexity: O(N*M*8*L) and space complexity O(1).
  • Handling edge cases: empty word, word longer than any row/column/diagonal, and single-character word.
  • Potential optimization: precompute first and last character positions or use a trie for multiple word queries.

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