/**
* struct TreeNode {
* int val;
* struct TreeNode *left;
* struct TreeNode *right;
* };
*/
class Solution {
public:
/**
*
* @param root TreeNode类 the root
* @return int整型vector
*/
vector<int> res{-1, -1};
TreeNode* pre = NULL;
void helper(TreeNode* root){
if(root == NULL) return;
helper(root -> left);
if(pre != NULL && pre -> val > root -> val && res[1] == -1) res[1] = pre -> val;
if(pre != NULL && pre -> val > root -> val && res[1] != -1) res[0] = root -> val;
pre = root;
helper(root -> right);
}
vector<int> findError(TreeNode* root) {
// write code here
helper(root);
return res;
}
};