From 49fc701e4897acd528e60ac9a67d0d85772dbb5b Mon Sep 17 00:00:00 2001
From: huhaonan <812559558@qq.com>
Date: Thu, 5 Jan 2023 21:42:53 +0800
Subject: [PATCH 1/3] =?UTF-8?q?UPDATE=200222=20=E4=BF=AE=E6=94=B9=E5=85=B6?=
=?UTF-8?q?=E4=B8=AD=E4=B8=A4=E4=B8=AA=E9=94=99=E5=88=AB=E5=AD=97?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
...232\204\350\212\202\347\202\271\344\270\252\346\225\260.md" | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git "a/problems/0222.\345\256\214\345\205\250\344\272\214\345\217\211\346\240\221\347\232\204\350\212\202\347\202\271\344\270\252\346\225\260.md" "b/problems/0222.\345\256\214\345\205\250\344\272\214\345\217\211\346\240\221\347\232\204\350\212\202\347\202\271\344\270\252\346\225\260.md"
index b87877c9ef..10ac826496 100644
--- "a/problems/0222.\345\256\214\345\205\250\344\272\214\345\217\211\346\240\221\347\232\204\350\212\202\347\202\271\344\270\252\346\225\260.md"
+++ "b/problems/0222.\345\256\214\345\205\250\344\272\214\345\217\211\346\240\221\347\232\204\350\212\202\347\202\271\344\270\252\346\225\260.md"
@@ -188,7 +188,7 @@ public:
```CPP
if (root == nullptr) return 0;
-// 开始根据做深度和有深度是否相同来判断该子树是不是满二叉树
+// 开始根据左深度和右深度是否相同来判断该子树是不是满二叉树
TreeNode* left = root->left;
TreeNode* right = root->right;
int leftDepth = 0, rightDepth = 0; // 这里初始为0是有目的的,为了下面求指数方便
@@ -843,3 +843,4 @@ impl Solution {
+
From 0c77206ecae5acece7cc12572ed08682b3147c20 Mon Sep 17 00:00:00 2001
From: Zeeland
Date: Thu, 5 Jan 2023 22:01:19 +0800
Subject: [PATCH 2/3] =?UTF-8?q?update:=20=200104.=E4=BA=8C=E5=8F=89?=
=?UTF-8?q?=E6=A0=91=E7=9A=84=E6=9C=80=E5=A4=A7=E6=B7=B1=E5=BA=A6:=20?=
=?UTF-8?q?=E4=BC=98=E5=8C=96python=E4=BB=A3=E7=A0=81?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
...04\345\261\202\345\272\217\351\201\215\345\216\206.md" | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
diff --git "a/problems/0102.\344\272\214\345\217\211\346\240\221\347\232\204\345\261\202\345\272\217\351\201\215\345\216\206.md" "b/problems/0102.\344\272\214\345\217\211\346\240\221\347\232\204\345\261\202\345\272\217\351\201\215\345\216\206.md"
index 406242a786..3b68592fff 100644
--- "a/problems/0102.\344\272\214\345\217\211\346\240\221\347\232\204\345\261\202\345\272\217\351\201\215\345\216\206.md"
+++ "b/problems/0102.\344\272\214\345\217\211\346\240\221\347\232\204\345\261\202\345\272\217\351\201\215\345\216\206.md"
@@ -2532,20 +2532,18 @@ class Solution:
return 0
queue_ = [root]
- result = []
+ depth = 0
while queue_:
length = len(queue_)
- sub = []
for i in range(length):
cur = queue_.pop(0)
sub.append(cur.val)
#子节点入队列
if cur.left: queue_.append(cur.left)
if cur.right: queue_.append(cur.right)
- result.append(sub)
+ depth += 1
-
- return len(result)
+ return depth
```
Go:
From abedcbbe040fff779f54ed7a68204e677bcaa24e Mon Sep 17 00:00:00 2001
From: Frank Mao
Date: Fri, 6 Jan 2023 00:35:56 +0800
Subject: [PATCH 3/3] =?UTF-8?q?0150.=E9=80=86=E6=B3=A2=E5=85=B0=E8=A1=A8?=
=?UTF-8?q?=E8=BE=BE=E5=BC=8F=E6=B1=82=E5=80=BC=20=E6=B7=BB=E5=8A=A0?=
=?UTF-8?q?=E6=9B=B4=E5=BF=AB=E9=80=9F=E7=9A=84python=E8=A7=A3?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
...76\345\274\217\346\261\202\345\200\274.md" | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
diff --git "a/problems/0150.\351\200\206\346\263\242\345\205\260\350\241\250\350\276\276\345\274\217\346\261\202\345\200\274.md" "b/problems/0150.\351\200\206\346\263\242\345\205\260\350\241\250\350\276\276\345\274\217\346\261\202\345\200\274.md"
index 176ea6875e..f0323bc4ff 100644
--- "a/problems/0150.\351\200\206\346\263\242\345\205\260\350\241\250\350\276\276\345\274\217\346\261\202\345\200\274.md"
+++ "b/problems/0150.\351\200\206\346\263\242\345\205\260\350\241\250\350\276\276\345\274\217\346\261\202\345\200\274.md"
@@ -163,6 +163,25 @@ class Solution {
python3
+```python
+from operator import add, sub, mul
+
+class Solution:
+ op_map = {'+': add, '-': sub, '*': mul, '/': lambda x, y: int(x / y)}
+
+ def evalRPN(self, tokens: List[str]) -> int:
+ stack = []
+ for token in tokens:
+ if token not in {'+', '-', '*', '/'}:
+ stack.append(int(token))
+ else:
+ op2 = stack.pop()
+ op1 = stack.pop()
+ stack.append(self.op_map[token](op1, op2)) # 第一个出来的在运算符后面
+ return stack.pop()
+```
+
+另一种可行,但因为使用eval相对较慢的方法:
```python
class Solution:
def evalRPN(self, tokens: List[str]) -> int: