Thales interview question

Typical medium leetcode questions, involving arrays.