We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent a4e8c5e commit fb99aecCopy full SHA for fb99aec
25. 颜色分类.md
@@ -1,7 +1,10 @@
1
***给定一个包含红色、白色和蓝色、共 n 个元素的数组 nums ,原地对它们进行排序,使得相同颜色的元素相邻,并按照红色、白色、蓝色顺序排列。我们使用整数 0、 1 和 2 分别表示红色、白色和蓝色。***
2
3
```
4
-单指针+对数组进行两次遍历。在第一次遍历中,我们将数组中所有的 0 交换到数组的头部。在第二次遍历中,我们将数组中所有的 1 交换到头部的 0 之后。此时,所有的 2 都出现在数组的尾部,这样我们就完成了排序。
+#单指针+对数组进行两次遍历。
5
+#在第一次遍历中,我们将数组中所有的 0 交换到数组的头部。
6
+#在第二次遍历中,我们将数组中所有的 1 交换到头部的 0 之后。此时,所有的 2 都出现在数组的尾部,这样我们就完成了排序。
7
+
8
class Solution:
9
def sortColors(self, nums: List[int]) -> None:
10
"""
@@ -21,7 +24,9 @@ class Solution:
21
24
22
25
23
26
-双指针Ref:https://leetcode.cn/problems/sort-colors/solution/yan-se-fen-lei-by-leetcode-solution/
27
+#双指针
28
+#Ref:https://leetcode.cn/problems/sort-colors/solution/yan-se-fen-lei-by-leetcode-solution/
29
30
31
32
0 commit comments