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 0cf08f5 commit 78bf85cCopy full SHA for 78bf85c
README.md
@@ -10,6 +10,8 @@ leetcode 测试
10
11
##### 包含的内容如下
12
13
+https://leetcode.cn/problems/di-string-match
14
+
15
https://leetcode.cn/problems/reshape-the-matrix/
16
17
https://leetcode.cn/problems/sZ59z6/
di-string-match/index.ts
@@ -0,0 +1,13 @@
1
+export default function diStringMatch(s: string): number[] {
2
+ const n = s.length, ans = new Array<number>();
3
+ let left = 0, right = n;
4
+ for (let i = 0; i < n; i++) {
5
+ if (s.charCodeAt(i) === "I".charCodeAt(0)) {
6
+ ans.push(left++);
7
+ } else {
8
+ ans.push(right--);
9
+ }
+ ans.push(left);
+ return ans;
+}
0 commit comments