You are given a string s and a character ch that occurs at least once in s.
For each index i in the string, calculate the shortest distance between i and any occurrence of ch in s.
The distance between two indices i and j is defined as abs(i - j) (the absolute difference).
Return an array of integers answer, where answer[i] is the distance from index i to the closest occurrence of ch.
Input: s = "datascience", c = "e"
Output: [7, 6, 5, 4, 3, 2, 1, 0, 1, 1, 0]
Input: s = "aeroplane", c= "a"
Output: [0, 1, 2, 3, 2, 1, 0, 1, 2]
Accepted:
Submission: