bool isDUI(TreeNode* root) { if (root == NULL) return true; bool l = false; bool r = false; l = isDUI(root->left); r = isDUI(root->right); bool isOK = true; if (root->left != NULL) isOK = isOK && (root->left->val < root->val); if (root->right != NULL) isOK = isOK && (root->right->val > root->val); if (l&&r&&isOK) return true; else return false; }