Amazon interview question

A LeetCode medium question about number pairs