- Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathindex.test.ts
116 lines (106 loc) · 2.82 KB
/
index.test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
import*asassertsfrom"https://deno.land/std@0.125.0/testing/asserts.ts";
import*aslogfrom"https://deno.land/std@0.125.0/log/mod.ts";
import{minSubArrayLen}from"./index.ts";
log.info("209. Minimum size subarray sum");
Deno.test({
name: `
Input: s = 5, nums = []
Output: 0
`,
fn(): void{
constresult=minSubArrayLen(5,[]);
asserts.assertEquals(0,result);
},
});
Deno.test({
name: `
Input: s = 5, nums = [1]
Output: 0
`,
fn(): void{
constresult=minSubArrayLen(5,[1]);
asserts.assertEquals(0,result);
},
});
Deno.test({
name: `
Input: s = 7, nums = [2,3,1,2,4,3]
Output: 2
Explanation: the subarray [4,3] has the minimal length under the problem constraint.
`,
fn(): void{
constresult=minSubArrayLen(7,[2,3,1,2,4,3]);
asserts.assertEquals(2,result);
},
});
Deno.test({
name: `
Input: s = 10, nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
Output: 10
Explanation: the subarray [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] has the minimal length under the problem constraint.
`,
fn(): void{
constresult=minSubArrayLen(10,[1,1,1,1,1,1,1,1,1,1]);
asserts.assertEquals(10,result);
},
});
Deno.test({
name: `
Input: s = 9, nums = [1, 1, 1, 1, 1, 1, 1, 1, 1, 9]
Output: 1
Explanation: the subarray [9] has the minimal length under the problem constraint.
`,
fn(): void{
constresult=minSubArrayLen(9,[1,1,1,1,1,1,1,1,1,9]);
asserts.assertEquals(1,result);
},
});
Deno.test({
name: `
Input: s = 55, nums = [1, 2, 3, 4, 5, 6, 7, 8, 9]
Output: 0
`,
fn(): void{
constresult=minSubArrayLen(55,[1,2,3,4,5,6,7,8,9]);
asserts.assertEquals(0,result);
},
});
Deno.test({
name: `
Input: s = 55, nums = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
Output: 10
Explanation: the subarray [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] has the minimal length under the problem constraint.
`,
fn(): void{
constresult=minSubArrayLen(55,[1,2,3,4,5,6,7,8,9,10]);
asserts.assertEquals(10,result);
},
});
Deno.test({
name: `
Input: s = 99, nums = [100, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
Output: 1
Explanation: the subarray [100] has the minimal length under the problem constraint.
`,
fn(): void{
constresult=minSubArrayLen(
99,
[100,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1],
);
asserts.assertEquals(1,result);
},
});
Deno.test({
name: `
Input: s = 99, nums = [1, 98, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
Output: 2
Explanation: the subarray [1,98] has the minimal length under the problem constraint.
`,
fn(): void{
constresult=minSubArrayLen(
99,
[1,98,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1],
);
asserts.assertEquals(2,result);
},
});