Solve jump maximization and palindromic path queries | Uber Interview Question