20. Shortest Distance to a Character
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 shortest distance from s[i]
to the character c
in s
.
Example 1:
Example 2:
Solution: ( Min Array )
Taking Distance from left side Taking Distance from right side
Time Complexity: O(n)
Last updated