/**
* struct TreeNode {
* int val;
* struct TreeNode *left;
* struct TreeNode *right;
* };
*/
class Solution {
public:
/**
*
* @param root TreeNode类 the root
* @return int整型vector
*/
vector<int> inorderVec;
void inOrder(TreeNode* root) {
if (!root) {
return;
}
inOrder(root->left);
inorderVec.push_back(root->val);
inOrder(root->right);
}
vector<int> findError(TreeNode* root) {
inOrder(root);
vector<int>temp = inorderVec, ret;
sort(temp.begin(), temp.end());
for (int i = 0; i < temp.size(); i++) {
if (temp[i] != inorderVec[i]) {
ret.push_back(temp[i]);
}
}
sort(ret.begin(),ret.end());
return ret;
}
};