Shortest Distance to a Character Problem

Shortest Distance to a Character Problem — ExecCode Easy DSA Practice

Solve the Shortest Distance to a Character problem on ExecCode. Free online easy DSA practice in Arrays - Logic Building. Write and run code in Java, C++, Python — no signup required to run.

Description Given a string s and a character c that occurs in s, return an array of integers answer where answer.length == s.length and answer[i] is the distance from index i to the closest occurrence of character c in s. The distance between two indices i and j is abs(i - j), w…

Practice Shortest Distance to a Character free on ExecCode. Browse more ExecCode DSA problems.