Google Cloud interview question

An array manipution leetcode question.