first commit
This commit is contained in:
@@ -316,6 +316,33 @@ public:
|
||||
|
||||
|
||||
Java:
|
||||
```java
|
||||
class Solution {
|
||||
private int count = 0;
|
||||
public int minCameraCover(TreeNode root) {
|
||||
if (trval(root) == 0) count++;
|
||||
return count;
|
||||
}
|
||||
|
||||
private int trval(TreeNode root) {
|
||||
if (root == null) return -1;
|
||||
|
||||
int left = trval(root.left);
|
||||
int right = trval(root.right);
|
||||
|
||||
if (left == 0 || right == 0) {
|
||||
count++;
|
||||
return 2;
|
||||
}
|
||||
|
||||
if (left == 2 || right == 2) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
Python:
|
||||
@@ -330,4 +357,4 @@ Go:
|
||||
* 作者微信:[程序员Carl](https://mp.weixin.qq.com/s/b66DFkOp8OOxdZC_xLZxfw)
|
||||
* B站视频:[代码随想录](https://space.bilibili.com/525438321)
|
||||
* 知识星球:[代码随想录](https://mp.weixin.qq.com/s/QVF6upVMSbgvZy8lHZS3CQ)
|
||||
<div align="center"><img src=../pics/公众号.png width=450 alt=> </img></div>
|
||||
<div align="center"><img src=../pics/公众号.png width=450 alt=> </img></div>
|
||||
Reference in New Issue
Block a user