Solve palindrome pairs and key path | Airbnb Coding Question