-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
92ff159
commit 652a1a2
Showing
18 changed files
with
98 additions
and
71 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { isValid } from './isValid'; | ||
|
||
describe('20. Valid Parentheses', () => { | ||
test('isValid', () => { | ||
expect(isValid('()')).toBe(true); | ||
expect(isValid('()[]{}')).toEqual(true); | ||
expect(isValid('(]')).toEqual(false); | ||
}); | ||
}); |
File renamed without changes.
22 changes: 0 additions & 22 deletions
22
src/page-1/21. Merge Two Sorted Lists/merge-two-lists.spec.ts
This file was deleted.
Oops, something went wrong.
30 changes: 30 additions & 0 deletions
30
src/page-1/21. Merge Two Sorted Lists/mergeTwoLists.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { stringify } from 'flatted'; | ||
|
||
import { generateLinkedList } from '~/utils/linked-list'; | ||
|
||
import { mergeTwoLists } from './mergeTwoLists'; | ||
|
||
describe('21. Merge Two Sorted Lists', () => { | ||
test('mergeTwoLists', () => { | ||
{ | ||
const list1 = generateLinkedList([1, 2, 4]); | ||
const list2 = generateLinkedList([1, 3, 4]); | ||
const expected = generateLinkedList([1, 1, 2, 3, 4, 4]); | ||
expect(stringify(mergeTwoLists(list1, list2))).toBe(stringify(expected)); | ||
} | ||
|
||
{ | ||
const list1 = generateLinkedList([]); | ||
const list2 = generateLinkedList([]); | ||
const expected = generateLinkedList([]); | ||
expect(stringify(mergeTwoLists(list1, list2))).toBe(stringify(expected)); | ||
} | ||
|
||
{ | ||
const list1 = generateLinkedList([]); | ||
const list2 = generateLinkedList([0]); | ||
const expected = generateLinkedList([0]); | ||
expect(stringify(mergeTwoLists(list1, list2))).toBe(stringify(expected)); | ||
} | ||
}); | ||
}); |
File renamed without changes.
8 changes: 0 additions & 8 deletions
8
src/page-1/26. Remove Duplicates from Sorted Array/remove-duplicates.spec.ts
This file was deleted.
Oops, something went wrong.
17 changes: 17 additions & 0 deletions
17
src/page-1/26. Remove Duplicates from Sorted Array/removeDuplicates.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { removeDuplicates } from './removeDuplicates'; | ||
|
||
describe('26. Remove Duplicates from Sorted Array', () => { | ||
test('removeDuplicates', () => { | ||
{ | ||
const nums = [1, 1, 2]; | ||
expect(removeDuplicates(nums)).toBe(2); | ||
expect(nums).toStrictEqual([1, 2]); | ||
} | ||
|
||
{ | ||
const nums = [0, 0, 1, 1, 1, 2, 2, 3, 3, 4]; | ||
expect(removeDuplicates(nums)).toBe(5); | ||
expect(nums).toStrictEqual([0, 1, 2, 3, 4]); | ||
} | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { removeElement } from './removeElement'; | ||
|
||
describe('27. Remove Element', () => { | ||
test('removeElement', () => { | ||
{ | ||
const nums = [3, 2, 2, 3]; | ||
const expected = [2, 2]; | ||
expect(removeElement(nums, 3)).toBe(expected.length); | ||
expect(nums.sort()).toStrictEqual(expected.sort()); | ||
} | ||
|
||
{ | ||
const nums = [0, 1, 2, 2, 3, 0, 4, 2]; | ||
const expected = [0, 1, 4, 0, 3]; | ||
expect(removeElement(nums, 2)).toBe(expected.length); | ||
expect(nums.sort()).toStrictEqual(expected.sort()); | ||
} | ||
}); | ||
}); |
File renamed without changes.
8 changes: 8 additions & 0 deletions
8
src/page-1/28. Find the Index of the First Occurrence in a String/strStr.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { strStr } from './strStr'; | ||
|
||
describe('28. Find the Index of the First Occurrence in a String', () => { | ||
test('strStr', () => { | ||
expect(strStr('sadbutsad', 'sad')).toBe(0); | ||
expect(strStr('leetcode', 'leeto')).toBe(-1); | ||
}); | ||
}); |
File renamed without changes.
This file was deleted.
Oops, something went wrong.
13 changes: 0 additions & 13 deletions
13
src/page-1/34. Find First and Last Position of Element in Sorted Array/search-range.spec.ts
This file was deleted.
Oops, something went wrong.
15 changes: 15 additions & 0 deletions
15
src/page-1/34. Find First and Last Position of Element in Sorted Array/searchRange.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { searchRange, searchRange2 } from './searchRange'; | ||
|
||
describe('34. Find First and Last Position of Element in Sorted Array', () => { | ||
it('searchRange', () => { | ||
expect(searchRange([5, 7, 7, 8, 8, 10], 8)).toStrictEqual([3, 4]); | ||
expect(searchRange([5, 7, 7, 8, 8, 10], 6)).toStrictEqual([-1, -1]); | ||
expect(searchRange([], 0)).toStrictEqual([-1, -1]); | ||
}); | ||
|
||
it('searchRange2', () => { | ||
expect(searchRange2([5, 7, 7, 8, 8, 10], 8)).toStrictEqual([3, 4]); | ||
expect(searchRange2([5, 7, 7, 8, 8, 10], 6)).toStrictEqual([-1, -1]); | ||
expect(searchRange2([], 0)).toStrictEqual([-1, -1]); | ||
}); | ||
}); |
File renamed without changes.