Robot fuel-constrained path
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) → intExamples
in
[[["S",".",".","T"]],5]out3What 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.
0:00 of about 35 min
solution.py
InputExpectedGot
[[["S",".",".","T"]],5]3not run yetsample