Amazon interview question

Technical Interview leetcode coding question