You are given an array of letters, arr, and a string, word. We know that word appears within arr as a subsequence. Identify the earliest occurrence of word in arr and move all those letters, in order, to the end of arr. You must do this in place.
Example 1:
- Input:
arr = ['a', 'g', 'o', 'o', 'd', 'r', 'e', 'a', 'd', 'i', 'n', 'g'], word = "od" - Output:
['a', 'g', 'o', 'r', 'e', 'a', 'd', 'i', 'n', 'g', 'o', 'd']
a
0
g
1
j
o
2
o
3
d
4
r
5
e
6
a
7
d
8
i
9
n
10
g
11
Step 1 / 3
Step 1:
Found indices for 'od': {2, 4}.
Pointers: j=2
Focus: select @ [2, 4]