We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 671543d commit c4fb62aCopy full SHA for c4fb62a
75.颜色分类.js
@@ -0,0 +1,30 @@
1
+/*
2
+ * @lc app=leetcode.cn id=75 lang=javascript
3
+ *
4
+ * [75] 颜色分类
5
+ */
6
+
7
+// @lc code=start
8
+/**
9
+ * @param {number[]} nums
10
+ * @return {void} Do not return anything, modify nums in-place instead.
11
12
+var sortColors = function(nums) {
13
+ const t = new Array(3).fill(0);
14
+ for (const n of nums) {
15
+ t[n]++;
16
+ }
17
+ let i = 0;
18
+ let j = 0;
19
+ while (i < t.length) {
20
+ if (t[i] === 0) {
21
+ i++;
22
+ continue;
23
24
+ nums[j] = i;
25
+ j++;
26
+ t[i]--;
27
28
+};
29
+// @lc code=end
30
0 commit comments