Allied Telesis interview question

standard leetcode question with arrays