Skip to content

Commit ccb459a

Browse files
committed
测试
1 parent 78cf531 commit ccb459a

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

shuffle-string/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
export default function restoreString(s: string, indices: number[]): string {
22
//@ts-ignore
33
return (
4+
//@ts-ignore
45
Array.prototype.reduce
56
//@ts-ignore
67
.call(s, (p, c, i) => ((p[indices[i]] = c), p), [...s])

shuffle-string/test.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { assertEquals } from "asserts";
2+
import restoreString from "./index.ts";
3+
4+
Deno.test("shuffle-string", () => {
5+
const s = "codeleet", indices = [4, 5, 6, 7, 0, 2, 1, 3], 输出 = "leetcode";
6+
assertEquals(restoreString(s, indices), 输出);
7+
});
8+
9+
Deno.test("shuffle-string", () => {
10+
const s = "abc", indices = [0, 1, 2], 输出 = "abc";
11+
assertEquals(restoreString(s, indices), 输出);
12+
});

0 commit comments

Comments
 (0)