Back to Questions

Shortest Distance to Character (Queue)

124.4K viewsAsked at Netflix
Easy

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

Practice answering orally or with text to get instant AI feedback.

Practice with This Question