Closest Distance to Character
Given a string s and a character c, return a new list of integers of the same length as s where for each index i its value is set the closest distance of s[i] to c. You can assume c exists in s.
Constraints
- n ≤ 100,000where- nis the length of- s
https://binarysearch.com/problems/Closest-Distance-to-Character
Examples
Example 1
Input
- s = aabaab
- c = b
Output
- answer = [2, 1, 0, 1, 1, 0]
 
       
      
Leave a comment