Skip to content

Commit 693728c

Browse files
committed
测试
1 parent f26ccce commit 693728c

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed

range-sum-query-2d-immutable/index.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
export default function NumMatrix(matrix: number[][]) {
1+
export default interface NumMatrix {
2+
sumRegion(row1: number, col1: number, row2: number, col2: number): number;
3+
}
4+
5+
export default function NumMatrix(matrix: number[][]): NumMatrix {
26
const m = matrix.length;
37
const n = matrix[0].length;
48
const sums: number[][] = Array.from({ length: m + 1 }).map(() =>

range-sum-query-2d-immutable/test.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import { assertEquals } from "https://deno.land/[email protected]/testing/asserts.ts";
2+
import { runScript } from "leetcode-class";
3+
import NumMatrix from "./index.ts";
4+
Deno.test("range-sum-query-2d-immutable", () => {
5+
assertEquals(
6+
runScript(
7+
["NumMatrix", "sumRegion", "sumRegion", "sumRegion"],
8+
[
9+
[
10+
[
11+
[3, 0, 1, 4, 2],
12+
[5, 6, 3, 2, 1],
13+
[1, 2, 0, 1, 5],
14+
[4, 1, 0, 1, 7],
15+
[1, 0, 3, 0, 5],
16+
],
17+
],
18+
[2, 1, 4, 3],
19+
[1, 1, 2, 2],
20+
[1, 2, 2, 4],
21+
],
22+
[NumMatrix],
23+
),
24+
[null, 8, 11, 12],
25+
);
26+
});

0 commit comments

Comments
 (0)