Largest bst in a binary tree

hii i understand the question but cant build function that will tell at which position the bst is largest please help me to build the function

Approach
you have to call on both parts of tree (left subtree and right subtree)
and get back 2 main things

  1. is this subtree is BST?
  2. size of subtree in left or right part

and now to check current subtree is bst or not
you need 2 things

  1. upper bound of node value( means max value it should have)
  2. lower bound of node value (min value it should have)
    these 2 things are required because for a valid BST
    left part should contains element less than root node and right part should contains elements greater than root node

i recommend to write code at your own first
then you can also take reference or hint from here
Reference Code

i made the approach but ek problem aa rahi hai random input ke liye work fine but when i go to submit the code 3 test case pass ho rahe hai last wala pass nahi ho raha .help me in finding out error please
code: https://ide.codingblocks.com/s/582589