class Solution {public: vector V; void postTree(TreeNode* node) { if (node != NULL) { if (node->left != NULL) { postTree(node->left); } V.push_back(node->val); if (node->right != NULL) { postTree(node->right); } } } bool isValidBST(TreeNode* root) { postTree(root); for (int i = 1; i < V.size(); i++) { if (V[i] <= V[i - 1]) { return false; } } return true; }};