Skip to content

Commit 7580743

Browse files
add 998
1 parent 57aa6ac commit 7580743

File tree

3 files changed

+37
-1
lines changed

3 files changed

+37
-1
lines changed

README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -339,4 +339,5 @@ LeetCode
339339
|0994|[Rotting Oranges](https://leetcode.com/problems/rotting-oranges/) | c | [c++](./src/0994-Rotting-Oranges/0994.cpp) |[python](./src/0994-Rotting-Oranges/0994.py)|||Easy|
340340
|0995|[Minimum Number of K Consecutive Bit Flips](https://leetcode.com/problems/minimum-number-of-k-consecutive-bit-flips/) | c | [c++](./src/0995-Minimum-Number-of-K-Consecutive-Bit-Flips/0995.cpp) |[python](./src/0995-Minimum-Number-of-K-Consecutive-Bit-Flips/0995.py)|||Hard|
341341
|0996|[Number of Squareful Arrays](https://leetcode.com/problems/number-of-squareful-arrays/) | c | [c++](./src/0996-Number-of-Squareful-Arrays/0996.cpp) |[python](./src/0996-Number-of-Squareful-Arrays/0996.py)|||Hard|
342-
|0997|[Find the Town Judge](https://leetcode.com/problems/find-the-town-judge/) | c | [c++](./src/0997-Find-the-Town-Judge/0997.cpp) |[python](./src/0997-Find-the-Town-Judge/0997.py)|||Easy|
342+
|0997|[Find the Town Judge](https://leetcode.com/problems/find-the-town-judge/) | c | [c++](./src/0997-Find-the-Town-Judge/0997.cpp) |[python](./src/0997-Find-the-Town-Judge/0997.py)|||Easy|
343+
|0998|[Maximum Binary Tree II](https://leetcode.com/problems/maximum-binary-tree-ii/) | c | [c++](./src/0998-Maximum-Binary-Tree-II/0998.cpp) |[python](./src/0998-Maximum-Binary-Tree-II/0998.py)|||Medium|
+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
static int x = []() {std::ios::sync_with_stdio(false); cin.tie(0); return 0; }();
2+
class Solution
3+
{
4+
public:
5+
TreeNode* insertIntoMaxTree(TreeNode* root, int val)
6+
{
7+
if (root->val < val)
8+
{
9+
TreeNode* res = new TreeNode(val);
10+
res->left = root;
11+
return res;
12+
}
13+
14+
if (root->right != nullptr) root->right = insertIntoMaxTree(root->right, val);
15+
else
16+
{
17+
TreeNode* res = new TreeNode(val);
18+
root->right = res;
19+
}
20+
return root;
21+
}
22+
};
+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
class Solution:
2+
def insertIntoMaxTree(self, root: TreeNode, val: int) -> TreeNode:
3+
if root.val < val:
4+
tmp = TreeNode(val)
5+
tmp.left = root
6+
return tmp
7+
8+
if root.right:
9+
root.right = self.insertIntoMaxTree(root.right, val)
10+
else:
11+
tmp = TreeNode(val)
12+
root.right = tmp
13+
return root

0 commit comments

Comments
 (0)