I am a beginner,why I submit when case is [1] ,expected answer is false,but when run,expected answer is true

• /**

• Definition for a binary tree node.
• struct TreeNode {
• ``````int val;
``````
• ``````TreeNode *left;
``````
• ``````TreeNode *right;
``````
• ``````TreeNode(int x) : val(x), left(NULL), right(NULL) {}
``````
• };
*/
class Solution {
public:
int my_res;
bool my_first;
bool my_tag;
void my_dfs(TreeNode *root)
{
if (root->left!=NULL)
{
my_dfs(root->left);
}
int p=root->val;
if (my_first)
{
my_res=p;
}
else
{
if (p<=my_res)
{
my_tag=false;
return;
}
else
{
my_res=p;
}
}
my_first=false;
if (root->right!=NULL)
{
my_dfs(root->right);
}
}

bool isValidBST(TreeNode* root) {
if (root==NULL)
{
return true;
}
if (root->left==NULL&&root->right==NULL)
{
return true;
}
my_tag=true;
my_first=true;
my_res=0;
my_dfs(root);
return my_tag;
}

};

• I also got this problem, there must be something wrong with test cases.

• The same problem when running test case 71:

Input:`[1]`

Output: `True`

Expected: `False`

• Sorry for the introduced error. I have just fixed it. Your program should be accepted now. Thanks!

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.