Velikost videa: 1280 X 720853 X 480640 X 360
Zobrazit ovladače přehrávání
Automatické přehrávání
Přehrát
Table of Contents0:00 Problem Statement0:52 Solution - Python2:29 Solution - C++
class Solution: def is_bst_util(self, root): if not root: return True if not self.is_bst_util(root.left): return False if self.prev and root.data
class Solution { public: Node *prev; bool is_bst_util(Node *root) { if (!root) return true; if (!is_bst_util(root->left)) return false; if (prev and root->data data) return false; prev = root; return is_bst_util(root->right); } bool isBST(Node* root) { prev = NULL; return is_bst_util(root); }};
Table of Contents
0:00 Problem Statement
0:52 Solution - Python
2:29 Solution - C++
class Solution:
def is_bst_util(self, root):
if not root:
return True
if not self.is_bst_util(root.left):
return False
if self.prev and root.data
class Solution {
public:
Node *prev;
bool is_bst_util(Node *root) {
if (!root)
return true;
if (!is_bst_util(root->left))
return false;
if (prev and root->data data)
return false;
prev = root;
return is_bst_util(root->right);
}
bool isBST(Node* root) {
prev = NULL;
return is_bst_util(root);
}
};