diff --git a/problems/0098.验证二叉搜索树.md b/problems/0098.验证二叉搜索树.md index 184060a5..319ad1aa 100644 --- a/problems/0098.验证二叉搜索树.md +++ b/problems/0098.验证二叉搜索树.md @@ -791,6 +791,20 @@ impl Solution { } } ``` +### C# +```C# +// 递归 +public long val = Int64.MinValue; +public bool IsValidBST(TreeNode root) +{ + if (root == null) return true; + bool left = IsValidBST(root.left); + if (root.val > val) val = root.val; + else return false; + bool right = IsValidBST(root.right); + return left && right; +} +```
diff --git a/problems/0530.二叉搜索树的最小绝对差.md b/problems/0530.二叉搜索树的最小绝对差.md
index 56911858..f08df577 100644
--- a/problems/0530.二叉搜索树的最小绝对差.md
+++ b/problems/0530.二叉搜索树的最小绝对差.md
@@ -647,6 +647,27 @@ impl Solution {
}
}
```
+### C#
+```C#
+// 递归
+public class Solution
+{
+ public List