Premium
Maze Traversal (Find a Path in a Grid)
Given a 2D grid of 0/1 (0=open, 1=wall), determine if a path exists from start to end using 4-direction moves. Use BFS/DFS with visited tracking. Complexity: O(rows*cols) time, O(rows*cols) space.
What you’ll build / What this tests
This premium javascript coding focuses on Maze Traversal (Find a Path in a Grid). You’ll apply algorithms and grid thinking with intermediate level constraints. The prompt emphasizes Given a 2D grid of 0/1 (0=open, 1=wall), determine if a path exists from start to….
Learning goals
- Translate the prompt into a clear javascript API signature and return shape.
- Apply algorithms, grid, arrays techniques to implement maze traversal (find a path in a grid).
- Handle intermediate edge cases without sacrificing readability.
- Reason about time/space complexity and trade-offs in javascript.
Key decisions to discuss
- Define the exact input/output contract before coding.
- Choose iteration vs higher-order methods for readability.
- Prioritize predictable edge-case handling over micro-optimizations.
Evaluation rubric
- Correctness: covers required behaviors and edge cases.
- Clarity: readable structure and predictable control flow.
- Complexity: avoids unnecessary work for large inputs.
- API discipline: no mutation of inputs; returns expected shape.
- Testability: solution is easy to unit test.
Constraints / Requirements
- Preserve input order and handle empty arrays safely.
- Do not mutate input arrays; preserve item order.
- Handle empty or missing inputs without throwing errors.
- Keep runtime close to linear time where possible.
- Prefer a pure function: no side effects beyond the return value.
Mini snippet (usage only)
// Example usage
const grid = /* maze traversal (find a path in a grid) input */;
const start = /* config */;
const result = hasPath(grid, start);
console.log(result);
// Edge case check
const empty = grid && start ?? null;
const fallback = hasPath(grid, start);
console.log(fallback);
// Expected: describe output shape, not the implementation
// (no solution code in preview)Common pitfalls
- Mutating inputs instead of returning a new value.
- Skipping edge cases like empty input, duplicates, or nulls.
- Overlooking time complexity for large inputs.
Related questions
Upgrade to FrontendAtlas Premium to unlock this challenge. Already upgraded? Sign in to continue.