The Trade Desk Interview Question

Common interview-style problem in JS