We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent f266c68 commit cc8a783Copy full SHA for cc8a783
0968. Binary Tree Cameras.cpp
@@ -0,0 +1,30 @@
1
+// 968.✅ Binary Tree Cameras
2
+
3
+class Solution
4
+{
5
+public:
6
+ int cam = 0;
7
+ int minCameraCover(TreeNode *root)
8
+ {
9
+ if (Camera(root) == "Want")
10
+ ++cam;
11
+ return cam;
12
+ }
13
14
+ string Camera(TreeNode *root)
15
16
+ if (root == NULL)
17
+ return "Ok";
18
+ string left = Camera(root->left);
19
+ string right = Camera(root->right);
20
21
+ if (left == "Want" || right == "Want")
22
23
24
+ return "Provide";
25
26
+ else if (left == "Provide" || right == "Provide")
27
28
+ return "Want";
29
30
+};
0 commit comments