Amazon Interview Question

A leetcode screening question. Data structures