Nearest Marker Distance for Every Position

Asked at Snowflake · Coding Questions · Difficulty: Easy

Given a string `s` and a single marker character, compute for every index of `s` how far away the closest occurrence of that character is. The distance between indexes `i` and `j` is `|i - j|`, so an index that holds the marker itself has distance 0.

Loading the problem…