Solve tree traversal and interval merging tasks | Meta Interview Question