Amazon Interview Question

On the HackerRank platform (like most OAs) with a leet-code style medium/easy problem