Skip to content

Commit 82e194f

Browse files
committed
Fixed isValidBST()
1 parent 3f2272a commit 82e194f

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

C++/chapTree.tex

+3-3
Original file line numberDiff line numberDiff line change
@@ -1447,15 +1447,15 @@ \subsubsection{分析}
14471447
\subsubsection{代码}
14481448

14491449
\begin{Code}
1450-
// LeetCode, Validate Binary Search Tree
1450+
// Validate Binary Search Tree
14511451
// 时间复杂度O(n),空间复杂度O(\logn)
14521452
class Solution {
14531453
public:
14541454
bool isValidBST(TreeNode* root) {
1455-
return isValidBST(root, INT_MIN, INT_MAX);
1455+
return isValidBST(root, LONG_MIN, LONG_MAX);
14561456
}
14571457

1458-
bool isValidBST(TreeNode* root, int lower, int upper) {
1458+
bool isValidBST(TreeNode* root, long long lower, long long upper) {
14591459
if (root == nullptr) return true;
14601460

14611461
return root->val > lower && root->val < upper

0 commit comments

Comments
 (0)