Code Room
CodingHardcod-g735
Subject Grid traversalLevel Senior–Staff~35 minCommon in Algorithms & data structures interviewsIndustries Software development, Computer games

Question

A delivery robot moves on a grid of characters: 'S' start, 'T' target, '.' open, '#' wall, 'F' fuel station. Each step into an open/target/fuel cell consumes 1 unit of fuel; the robot starts full with `capacity` units and cannot move with 0 fuel remaining. Stepping onto an 'F' cell refills fuel back to `capacity` (after paying the 1 unit to enter it). Return the minimum number of steps to reach 'T', or -1 if impossible. The grid has exactly one 'S' and one 'T'.

Implement
min_steps_with_fuel(grid: list[list[str]], capacity: int) → int
Examples
in[[["S",".",".","T"]],5]out3
What a strong answer looks like

State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.

Vibe coding: describe the solution in plain language (or narrate it) and the coach grades your approach. Generating runnable code from your description is coming next.

Run or narrate your approach, then ask the coach.