Airbnb Interview Question

Medium difficulty recursion problem