Facebook | Phone | Shortest Distance to a Character

Difficulty: MEDIUMCategory: InterviewExperienceFrequency: 1Asked On 2020-04-27Added By Anonymous
Source: Link

Company: Meta (Facebook)
Role: e3
Interview Stage: Phone Screen
Location: unknown
Year: unknown

Original Post Content:

https://leetcode.com/problems/shortest-distance-to-a-character/

Given a String and a character, output the array such that, each character's minimum distance from the given character.

Example:
Input: s = "instagram", c = "a"
Output: [4, 3, 2, 1, 0, 1, 1, 0, 1]

Comments