Skip to content

Commit 6414fe3

Browse files
authored
Improved tasks 57-66
1 parent 9a33707 commit 6414fe3

File tree

5 files changed

+47
-10
lines changed

5 files changed

+47
-10
lines changed

src/main/ts/g0001_0100/s0057_insert_interval/solution.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ function insert(intervals: number[][], newInterval: number[]): number[][] {
1717
}
1818
res[l] = [
1919
Math.min(newInterval[0], l === n ? newInterval[0] : intervals[l][0]),
20-
Math.max(newInterval[1], r === -1 ? newInterval[1] : intervals[r][1])
20+
Math.max(newInterval[1], r === -1 ? newInterval[1] : intervals[r][1]),
2121
]
2222
for (let i = l + 1, j = r + 1; j < n; i++, j++) {
2323
res[i] = intervals[j]

src/test/ts/g0001_0100/s0057_insert_interval/solution.test.ts

+28-2
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,35 @@ import { insert } from 'src/main/ts/g0001_0100/s0057_insert_interval/solution'
33
import { expect, test } from 'vitest'
44

55
test('insert', () => {
6-
expect(insert([[1,3],[6,9]], [2,5])).toEqual([[1,5],[6,9]])
6+
expect(
7+
insert(
8+
[
9+
[1, 3],
10+
[6, 9],
11+
],
12+
[2, 5],
13+
),
14+
).toEqual([
15+
[1, 5],
16+
[6, 9],
17+
])
718
})
819

920
test('insert2', () => {
10-
expect(insert( [[1,2],[3,5],[6,7],[8,10],[12,16]], [4,8])).toEqual([[1,2],[3,10],[12,16]])
21+
expect(
22+
insert(
23+
[
24+
[1, 2],
25+
[3, 5],
26+
[6, 7],
27+
[8, 10],
28+
[12, 16],
29+
],
30+
[4, 8],
31+
),
32+
).toEqual([
33+
[1, 2],
34+
[3, 10],
35+
[12, 16],
36+
])
1137
})

src/test/ts/g0001_0100/s0061_rotate_list/solution.test.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ import { expect, test } from 'vitest'
44
import { constructLinkedList } from '../../com_github_leetcode/linkedlistutils'
55

66
test('rotateRight', () => {
7-
expect(rotateRight(constructLinkedList([1,2,3,4,5]), 2).toString()).toEqual('4, 5, 1, 2, 3')
7+
expect(rotateRight(constructLinkedList([1, 2, 3, 4, 5]), 2).toString()).toEqual('4, 5, 1, 2, 3')
88
})
99

1010
test('rotateRight2', () => {
11-
expect(rotateRight(constructLinkedList([0,1,2]), 4).toString()).toEqual('2, 0, 1')
11+
expect(rotateRight(constructLinkedList([0, 1, 2]), 4).toString()).toEqual('2, 0, 1')
1212
})

src/test/ts/g0001_0100/s0063_unique_paths_ii/solution.test.ts

+13-2
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,20 @@ import { uniquePathsWithObstacles } from 'src/main/ts/g0001_0100/s0063_unique_pa
33
import { expect, test } from 'vitest'
44

55
test('uniquePathsWithObstacles', () => {
6-
expect(uniquePathsWithObstacles([[0,0,0],[0,1,0],[0,0,0]])).toEqual(2)
6+
expect(
7+
uniquePathsWithObstacles([
8+
[0, 0, 0],
9+
[0, 1, 0],
10+
[0, 0, 0],
11+
]),
12+
).toEqual(2)
713
})
814

915
test('uniquePathsWithObstacles2', () => {
10-
expect(uniquePathsWithObstacles([[0,1],[0,0]])).toEqual(1)
16+
expect(
17+
uniquePathsWithObstacles([
18+
[0, 1],
19+
[0, 0],
20+
]),
21+
).toEqual(1)
1122
})

src/test/ts/g0001_0100/s0066_plus_one/solution.test.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@ import { plusOne } from 'src/main/ts/g0001_0100/s0066_plus_one/solution'
33
import { expect, test } from 'vitest'
44

55
test('plusOne', () => {
6-
expect(plusOne([1,2,3])).toEqual([1,2,4])
6+
expect(plusOne([1, 2, 3])).toEqual([1, 2, 4])
77
})
88

99
test('plusOne2', () => {
10-
expect(plusOne([4,3,2,1])).toEqual([4,3,2,2])
10+
expect(plusOne([4, 3, 2, 1])).toEqual([4, 3, 2, 2])
1111
})
1212

1313
test('plusOne3', () => {
14-
expect(plusOne([9])).toEqual([1,0])
14+
expect(plusOne([9])).toEqual([1, 0])
1515
})

0 commit comments

Comments
 (0)