/ \ /
40 60 90 Output : -1Explanation: For the above test case no
sequence is possible. So output is -1.
You dont need to read input or print anything. Complete the function longestConsecutive() which takes root node as input parameter and returns the length of the longest consecutive increasing sequence (of at least length 2) in the given Binary Tree. If such a sequence does not exist, it returns -1.
Expected Time Complexity: O(N) Expected Auxiliary Space: O(Height of Tree)