# Shortest Distance to a Character
#
# Solution
# 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:
#
# Input: s = "loveleetcode", c = "e"
# Output: [3,2,1,0,1,0,0,1,2,2,1,0]
# Example 2:
#
# Input: s = "aaab", c = "b"
# Output: [3,2,1,0]
#
#
# Constraints:
#
# 1 <= s.length <= 104
# s[i] and c are lowercase English letters.
# c occurs at least once in s.


class Solution(object):
    def shortestToChar(self, s, c):
        """
        :type s: str
        :type c: str
        :rtype: List[int]
        """
        res = []
        for index, string in enumerate(s):
            if string == c:
                res.append(index)

        output = []
        for k in range(len(s)):
            temp = 999999
            for i in res:
                temp = min(temp, abs(k - i))
            output.append(temp)
        return output