dsa · easy

Playlist Min Moves

GreyOrangeArrayMathFoundation

songs is a circular playlist. current is the playing index, target is the song name. Return the minimum up/down moves. From the last song you may wrap to index 0 in **one** move.

Arguments

**Example:** songs=["a","b","c","d"], current=0, target="c"2. current=3, target="a"1.

Constraints

1 <= songs.length <= 100, unique names Hidden tests include near-max size for this bound; a slower-than-intended solution TLEs.

Examples

Example 1

Input:
["a","b","c","d"]
0
c

Expected:
2

Example 2

Input:
["a","b","c","d"]
3
a

Expected:
1

Open in the Dojo editor