Skip to content

Commit f292cba

Browse files
committed
Update 0968.监控二叉树,添加C#
1 parent 6b38053 commit f292cba

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

problems/0968.监控二叉树.md

+25
Original file line numberDiff line numberDiff line change
@@ -726,6 +726,31 @@ impl Solution {
726726
}
727727
}
728728

729+
```
730+
### C#
731+
```csharp
732+
public class Solution
733+
{
734+
public int res = 0;
735+
public int MinCameraCover(TreeNode root)
736+
{
737+
if (Traversal(root) == 0) res++;
738+
return res;
739+
}
740+
public int Traversal(TreeNode cur)
741+
{
742+
if (cur == null) return 2;
743+
int left = Traversal(cur.left);
744+
int right = Traversal(cur.right);
745+
if (left == 2 && right == 2) return 0;
746+
else if (left == 0 || right == 0)
747+
{
748+
res++;
749+
return 1;
750+
}
751+
else return 2;
752+
}
753+
}
729754
```
730755

731756
<p align="center">

0 commit comments

Comments
 (0)