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 921d2d5 commit e21aad2Copy full SHA for e21aad2
484-find-permutation.js
@@ -18,6 +18,31 @@ const findPermutation = function(s) {
18
return res;
19
};
20
21
+// another
22
+
23
+/**
24
+ * @param {string} s
25
+ * @return {number[]}
26
+ */
27
+const findPermutation = function(s) {
28
+ const n = s.length
29
+ const res = Array(n)
30
+ res[n] = n + 1
31
+ for(let i = 0; i < n;) {
32
+ let j = i
33
+ while(j < n && s[j] === 'D') j++
34
+ // console.log(j)
35
+ for(let k = j - i + 1; k > 0; k--) {
36
+ res[i] = j + 1
37
+ i++
38
+ j--
39
+ }
40
41
42
+ return res
43
+};
44
45
46
// another
47
48
/**
0 commit comments