Question
A grid contains 'S' start, 'T' target, '.' floor, '#' wall, and matched portal pairs marked by lowercase letters (each letter appears on at most two cells). A normal step to an orthogonally adjacent non-wall cell costs 1. Standing on a portal cell, you may teleport instantly (cost 0) to the other cell with the same letter. Return the minimum cost to get from 'S' to 'T', or -1 if unreachable. Exactly one 'S' and one 'T' exist.
min_steps_portals(grid: list[list[str]]) → int[[["S",".","a","#","#","#","a",".","T"]]]out4State 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.