Pinterest Interview Question

Tree/graph traversal question and optimized best route path