TIL Day8(June7)

leech gamer
Jun 7, 2021

I worked overtime today.

So I just solved an algorithm.

  • Shortest distance to every other character from given character

examples

IInput: S = “geeksforgeeks”, X = ‘e’
Output: [1, 0, 0, 1, 2, 3, 3, 2, 1, 0, 0, 1, 2]

IInput: S = “helloworld”, X = ‘o’
Output: [4, 3, 2, 1, 0, 1, 0, 1, 2, 3]

My solution

--

--