Airbnb interview question

balanced brackets, shortest flight path