01 · Question
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']