Skip to content

Commit a1f37da

Browse files
committed
using namespace insufficient_nodes_in_root_to_leaf_paths;
1 parent 49dd49f commit a1f37da

File tree

2 files changed

+28
-30
lines changed

2 files changed

+28
-30
lines changed
Lines changed: 26 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,38 @@
11
// +build ignore
22

33
#pragma once
4-
/**
5-
* Definition for a binary tree node.
6-
* struct TreeNode {
7-
* int val;
8-
* TreeNode *left;
9-
* TreeNode *right;
10-
* TreeNode(int x) : val(x), left(NULL), right(NULL) {}
11-
* };
12-
*/
13-
14-
// #include "../insert-into-a-binary-search-tree/TreeNode.hpp"
4+
155
import leetcode_treenode_cpp.TreeNode;
166
using namespace leetcode_treenode_cpp;
17-
class Solution {
18-
public:
19-
TreeNode* sufficientSubset(TreeNode* root, int limit)
7+
8+
namespace insufficient_nodes_in_root_to_leaf_paths
9+
{
10+
class Solution
2011
{
12+
public:
13+
TreeNode *sufficientSubset(TreeNode *root, int limit)
14+
{
2115

22-
if (!root)
23-
return root;
16+
if (!root)
17+
return root;
2418

25-
if (!root->left && !root->right) {
19+
if (!root->left && !root->right)
20+
{
2621

27-
if (root->val >= limit)
28-
return root;
22+
if (root->val >= limit)
23+
return root;
2924

30-
else
31-
return nullptr;
32-
}
25+
else
26+
return nullptr;
27+
}
3328

34-
root->left = sufficientSubset(root->left, limit - root->val);
35-
root->right = sufficientSubset(root->right, limit - root->val);
29+
root->left = sufficientSubset(root->left, limit - root->val);
30+
root->right = sufficientSubset(root->right, limit - root->val);
3631

37-
if (!root->left && !root->right)
38-
return nullptr;
39-
else
40-
return root;
41-
}
42-
};
32+
if (!root->left && !root->right)
33+
return nullptr;
34+
else
35+
return root;
36+
}
37+
};
38+
}

insufficient-nodes-in-root-to-leaf-paths/test.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ using namespace leetcode_treenode_cpp;
1414
import leetcode_treenode_cpp.traversalTreeNode;
1515
import leetcode_treenode_cpp.LeetCodeTreeNodeToString;
1616
import leetcode_treenode_cpp.parseLeetCodeBinaryTree;
17+
18+
using namespace insufficient_nodes_in_root_to_leaf_paths;
1719
void LeetCode1080TestExamples(std::string& root, int limit, std::string& output)
1820
{
1921
TreeNode* tree = nullptr;

0 commit comments

Comments
 (0)