Amazon Interview Question

A LeetCode medium question about number pairs