Back to Question
Shortest Distance to Character (Queue)
Question Explain
Given a string $S$ and a character $C$, return an array of integers representing the shortest distance from each character in $S$ to the character $C$. Use a two-pass linear scan or BFS.
Start Trying This Question Simulation
Click "Start Speaking" and answer the question naturally.