Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 7aef42d

Browse files
committed
Update 0098.验证二叉搜索树,添加C#版
1 parent ca89ca3 commit 7aef42d

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

‎problems/0098.验证二叉搜索树.md‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -791,6 +791,20 @@ impl Solution {
791791
}
792792
}
793793
```
794+
### C#
795+
```C#
796+
// 递归
797+
public long val = Int64.MinValue;
798+
public bool IsValidBST(TreeNode root)
799+
{
800+
if (root == null) return true;
801+
bool left = IsValidBST(root.left);
802+
if (root.val > val) val = root.val;
803+
else return false;
804+
bool right = IsValidBST(root.right);
805+
return left && right;
806+
}
807+
```
794808

795809
<p align="center">
796810
<a href="https://programmercarl.com/other/kstar.html" target="_blank">

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /