Available question text
For each index i in string s, compute the minimum absolute distance to the nearest occurrence of character c. This can be solved in linear time by tracking nearest c positions from the left and right (two-pass sweep).
Related questions
Continue with questions that share topics or the same question type.
- Find Shortest Distance Between Multiple Sources and Destinations in Matrix
Coding
- Shortest Distance After Road Addition Queries I
Coding
- Shortest Distance After Road Addition Queries II
Coding
- Shortest Distance from All Buildings
Coding · Array · Breadth-First Search · Matrix
Sources · 1 reference
These records explain where the question appears. A company tag or candidate report does not guarantee a future interview question.
Hello Interview · 1 record
No company association
Leetcode 821. Shortest Distance to a Character
Reported date not specified · 0 source reports
Source snapshot: Nov 12, 2026
View source