diff --git a/problems/0040.组合总和II.md b/problems/0040.组合总和II.md index fdccf140..55b66b22 100644 --- a/problems/0040.组合总和II.md +++ b/problems/0040.组合总和II.md @@ -296,7 +296,7 @@ class Solution { } ``` Python: -```py +```python class Solution: def combinationSum2(self, candidates: List[int], target: int) -> List[List[int]]: res = [] diff --git a/problems/0102.二叉树的层序遍历.md b/problems/0102.二叉树的层序遍历.md index 4b57a82a..1c10459f 100644 --- a/problems/0102.二叉树的层序遍历.md +++ b/problems/0102.二叉树的层序遍历.md @@ -93,10 +93,10 @@ class Solution: if not root: return [] - quene = [root] + queue = [root] out_list = [] - while quene: + while queue: length = len(queue) in_list = [] for _ in range(length): diff --git a/problems/0344.反转字符串.md b/problems/0344.反转字符串.md index 6bb5f87a..226d5b51 100644 --- a/problems/0344.反转字符串.md +++ b/problems/0344.反转字符串.md @@ -210,7 +210,20 @@ var reverseString = function(s) { }; ``` +Swift: +```swift +func reverseString(_ s: inout [Character]) { + var l = 0 + var r = s.count - 1 + while l < r { + // 使用元祖 + (s[l], s[r]) = (s[r], s[l]) + l += 1 + r -= 1 + } +} +```