Implement exponentiation and link tree neighbors | Meta Interview Question