Skip to content

Commit b4fb54e

Browse files
committed
feat(leetcode): solve 226 - Invert Binary Tree
1 parent 2afe662 commit b4fb54e

5 files changed

Lines changed: 41 additions & 16 deletions

File tree

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,24 +22,24 @@ Total 125
2222
2323
| Field | Value |
2424
|------|------|
25-
| Problem ID | 104 |
26-
| Title | Maximum Depth Of Binary Tree |
25+
| Problem ID | 226 |
26+
| Title | Invert Binary Tree |
2727
| Language | Python3 |
2828
| Runtime | 0 ms |
29-
| Memory | 20.3 MB |
29+
| Memory | 19.1 MB |
3030
3131
3232
💻 Languages Used
3333
34-
- **Python3** : 25
34+
- **Python3** : 26
3535
3636
## 📚 Recent Accepted Problems
3737
38+
- 226 Invert Binary Tree
3839
- 104 Maximum Depth Of Binary Tree
3940
- 235 Lowest Common Ancestor Of A Binary Search Tree
4041
- 124 Binary Tree Maximum Path Sum
4142
- 789 Kth Largest Element In A Stream
42-
- 1127 Last Stone Weight
4343
4444
4545
---
@@ -81,4 +81,4 @@ Git
8181
GitHub
8282
⏰ Last Sync
8383
84-
2026-07-06 19:56:26
84+
2026-07-06 19:56:28
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"submission_id": "2045547332",
3+
"question_id": "226",
4+
"title_slug": "invert-binary-tree",
5+
"language": "python3",
6+
"language_verbose": "Python3",
7+
"runtime": "0 ms",
8+
"memory": "19.1 MB",
9+
"status_code": 10,
10+
"timestamp": 1782376821
11+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Definition for a binary tree node.
2+
# class TreeNode:
3+
# def __init__(self, val=0, left=None, right=None):
4+
# self.val = val
5+
# self.left = left
6+
# self.right = right
7+
class Solution:
8+
def invertTree(self, root: Optional[TreeNode]) -> Optional[TreeNode]:
9+
if not root:
10+
return root
11+
self.invertTree(root.left)
12+
self.invertTree(root.right)
13+
root.left,root.right=root.right,root.left
14+
return root

storage/state.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
"last_submission_id": "2046953410"
2+
"last_submission_id": "2045552347"
33
}

storage/stats.json

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,13 @@
44
"medium": 56,
55
"hard": 6,
66
"languages": {
7-
"Python3": 25
7+
"Python3": 26
88
},
99
"recent_problems": [
10+
{
11+
"id": "226",
12+
"title": "Invert Binary Tree"
13+
},
1014
{
1115
"id": "104",
1216
"title": "Maximum Depth Of Binary Tree"
@@ -22,18 +26,14 @@
2226
{
2327
"id": "789",
2428
"title": "Kth Largest Element In A Stream"
25-
},
26-
{
27-
"id": "1127",
28-
"title": "Last Stone Weight"
2929
}
3030
],
3131
"last_problem": {
32-
"id": "104",
33-
"title": "Maximum Depth Of Binary Tree",
32+
"id": "226",
33+
"title": "Invert Binary Tree",
3434
"language": "Python3",
3535
"runtime": "0 ms",
36-
"memory": "20.3 MB"
36+
"memory": "19.1 MB"
3737
},
38-
"last_sync": "2026-07-06 19:56:26"
38+
"last_sync": "2026-07-06 19:56:28"
3939
}

0 commit comments

Comments
 (0)