Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 13b19ba

Browse files
authored
Improved tasks 22-25
1 parent 0624c1a commit 13b19ba

File tree

4 files changed

+58
-0
lines changed

4 files changed

+58
-0
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// tslint:disable:no-magic-numbers
2+
import { generateParenthesis } from 'src/main/ts/g0001_0100/s0022_generate_parentheses/solution'
3+
import { expect, test } from 'vitest'
4+
5+
test('generateParenthesis', () => {
6+
expect(generateParenthesis(3)).toEqual(['((()))', '(()())', '(())()', '()(())', '()()()'])
7+
})
8+
9+
test('generateParenthesis2', () => {
10+
expect(generateParenthesis(1)).toEqual(['()'])
11+
})
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// tslint:disable:no-magic-numbers
2+
import { ListNode } from 'src/main/ts/com_github_leetcode/listnode'
3+
import { mergeKLists } from 'src/main/ts/g0001_0100/s0023_merge_k_sorted_lists/solution'
4+
import { expect, test } from 'vitest'
5+
import { createSinglyLinkedList } from '../../com_github_leetcode/linkedlistutils'
6+
7+
test('mergeKLists', () => {
8+
const head1 = createSinglyLinkedList([1, 4, 5])
9+
const head2 = createSinglyLinkedList([1, 3, 4])
10+
const head3 = createSinglyLinkedList([2, 6])
11+
expect(mergeKLists([head1, head2, head3]).toString()).toEqual('1, 1, 2, 3, 4, 4, 5, 6')
12+
})
13+
14+
test('mergeKLists2', () => {
15+
const head1 = createSinglyLinkedList([1, 3, 5, 7, 11])
16+
const head2 = createSinglyLinkedList([2, 8, 12])
17+
const head3 = createSinglyLinkedList([4, 6, 9, 10])
18+
expect(mergeKLists([head1, head2, head3])?.toString()).toEqual('1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12')
19+
})
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// tslint:disable:no-magic-numbers
2+
import { swapPairs } from 'src/main/ts/g0001_0100/s0024_swap_nodes_in_pairs/solution'
3+
import { expect, test } from 'vitest'
4+
import { createSinglyLinkedList } from '../../com_github_leetcode/linkedlistutils'
5+
import { ListNode } from 'src/main/ts/com_github_leetcode/listnode'
6+
7+
test('swapPairs', () => {
8+
const listNode = createSinglyLinkedList([1, 2, 3, 4])
9+
expect(swapPairs(listNode).toString()).toEqual('2, 1, 4, 3')
10+
})
11+
12+
test('swapPairs2', () => {
13+
expect(swapPairs(new ListNode(1)).toString()).toEqual('1')
14+
})
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// tslint:disable:no-magic-numbers
2+
import { reverseKGroup } from 'src/main/ts/g0001_0100/s0025_reverse_nodes_in_k_group/solution'
3+
import { expect, test } from 'vitest'
4+
import { constructLinkedList } from '../../com_github_leetcode/linkedlistutils'
5+
6+
test('reverseKGroup', () => {
7+
const listNode = constructLinkedList([1, 2, 3, 4, 5])
8+
expect(reverseKGroup(listNode, 2).toString()).toEqual('2, 1, 4, 3, 5')
9+
})
10+
11+
test('reverseKGroup2', () => {
12+
const listNode = constructLinkedList([1, 2, 3, 4, 5])
13+
expect(reverseKGroup(listNode, 3).toString()).toEqual('3, 2, 1, 4, 5')
14+
})

0 commit comments

Comments
 (0)