Problem 821 · Easy

Shortest Distance to a Character

For each position in a string, find the distance to the nearest occurrence of a given character. The visual sweeps left to right and right to left to carry the closest distance along.

Open the interactive visualisation