Problem in largest BST in BT problem

This is my code It is running for all test cases except one please help me to correct it…

@Mukul70
your code is incorrect as it checks only immediate children!
see this test case:
7
5 4 3 7 6 1 8
3 4 7 5 1 6 8

answer is 3 but your output is 7.

This is my doubt link Please help…