Skip to content

Commit de1440d

Browse files
committed
format ts files
1 parent d10410a commit de1440d

File tree

62 files changed

+291
-284
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+291
-284
lines changed

typescript/@types/Node.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ declare class ListNode {
33
next: ListNode | null;
44
prev?: ListNode | null;
55
key?: number;
6-
6+
77
constructor(val: number, next?: ListNode | null);
88
constructor(options: { key?: number; value: number });
99
}
1010

1111
declare function createLinkedList(values: number[]): ListNode | null;
12-
declare function linkedListToArray(head: ListNode | null): number[];
12+
declare function linkedListToArray(head: ListNode | null): number[];

typescript/@types/global.d.ts

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,10 @@ declare global {
2525
val: number;
2626
key?: number;
2727

28-
constructor(valOrOptions: number | ListNodeConstructor, next: ListNode | null = null) {
28+
constructor(
29+
valOrOptions: number | ListNodeConstructor,
30+
next: ListNode | null = null
31+
) {
2932
if (typeof valOrOptions === 'object') {
3033
this.prev = null;
3134
this.next = null;
@@ -40,30 +43,34 @@ declare global {
4043
}
4144
};
4245

43-
(globalThis as any).createLinkedList = function(values: number[]): ListNode | null {
46+
(globalThis as any).createLinkedList = function (
47+
values: number[]
48+
): ListNode | null {
4449
if (values.length === 0) return null;
45-
50+
4651
const head = new ListNode(values[0]);
4752
let current = head;
48-
53+
4954
for (let i = 1; i < values.length; i++) {
5055
current.next = new ListNode(values[i]);
5156
current = current.next;
5257
}
53-
58+
5459
return head;
5560
};
5661

57-
(globalThis as any).linkedListToArray = function(head: ListNode | null): number[] {
62+
(globalThis as any).linkedListToArray = function (
63+
head: ListNode | null
64+
): number[] {
5865
const result: number[] = [];
5966
let current = head;
60-
67+
6168
while (current !== null) {
6269
result.push(current.val);
6370
current = current.next;
6471
}
65-
72+
6673
return result;
6774
};
6875

69-
export {};
76+
export {};
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { test, expect } from 'vitest';
22
import { twoSum } from './TwoSum';
33

4-
test("twoSum", () => {
4+
test('twoSum', () => {
55
const input = [2, 7, 11, 15];
66
expect(twoSum(input, 9)).toStrictEqual([0, 1]);
77
});
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
import { test, expect } from 'vitest';
22
import { lengthOfLongestSubstring } from './LongestSubstringWithoutRepeatingCharacters';
33

4-
test("lengthOfLongestSubstring1", () => {
5-
const input = "abcabcbb";
4+
test('lengthOfLongestSubstring1', () => {
5+
const input = 'abcabcbb';
66
expect(lengthOfLongestSubstring(input)).toEqual(3);
77
});
88

9-
test("lengthOfLongestSubstring2", () => {
10-
const input = "bbbbb";
9+
test('lengthOfLongestSubstring2', () => {
10+
const input = 'bbbbb';
1111
expect(lengthOfLongestSubstring(input)).toEqual(1);
1212
});
1313

14-
test("lengthOfLongestSubstring3", () => {
15-
const input = "pwwkew";
14+
test('lengthOfLongestSubstring3', () => {
15+
const input = 'pwwkew';
1616
expect(lengthOfLongestSubstring(input)).toEqual(3);
1717
});
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { test, expect } from 'vitest';
22
import { longestPalindrome } from './LongestPalindromicSubstring';
33

4-
test("longestPalindromicSubstring1", () => {
5-
const input = "babad";
6-
expect(longestPalindrome(input)).toBe("aba");
4+
test('longestPalindromicSubstring1', () => {
5+
const input = 'babad';
6+
expect(longestPalindrome(input)).toBe('aba');
77
});

typescript/problem_0007/ReverseInteger.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,28 @@
11
import { test, expect } from 'vitest';
22
import { reverse } from './ReverseInteger';
33

4-
test("Reverse Integer 1", () => {
4+
test('Reverse Integer 1', () => {
55
const input = 123;
66
const output = 321;
77

88
expect(reverse(input)).toBe(output);
99
});
1010

11-
test("Reverse Integer 2", () => {
11+
test('Reverse Integer 2', () => {
1212
const input = -123;
1313
const output = -321;
1414

1515
expect(reverse(input)).toBe(output);
1616
});
1717

18-
test("Reverse Integer 3", () => {
18+
test('Reverse Integer 3', () => {
1919
const input = 120;
2020
const output = 21;
2121

2222
expect(reverse(input)).toBe(output);
2323
});
2424

25-
test("Reverse Integer 4", () => {
25+
test('Reverse Integer 4', () => {
2626
const input = 0;
2727
const output = 0;
2828

typescript/problem_0017/LetterCombinationsOfAPhoneNumber.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,16 @@
1111
*/
1212

1313
const numbers = {
14-
"0": [" "],
15-
"1": [],
16-
"2": ["a", "b", "c"],
17-
"3": ["d", "e", "f"],
18-
"4": ["g", "h", "i"],
19-
"5": ["j", "k", "l"],
20-
"6": ["m", "n", "o"],
21-
"7": ["p", "q", "r", "s"],
22-
"8": ["t", "u", "v"],
23-
"9": ["w", "x", "y", "z"],
14+
'0': [' '],
15+
'1': [],
16+
'2': ['a', 'b', 'c'],
17+
'3': ['d', 'e', 'f'],
18+
'4': ['g', 'h', 'i'],
19+
'5': ['j', 'k', 'l'],
20+
'6': ['m', 'n', 'o'],
21+
'7': ['p', 'q', 'r', 's'],
22+
'8': ['t', 'u', 'v'],
23+
'9': ['w', 'x', 'y', 'z'],
2424
};
2525

2626
const letterCombinations = function (digits: string) {
@@ -44,7 +44,7 @@ const letterCombinations = function (digits: string) {
4444
}
4545
};
4646

47-
dfs(0, "");
47+
dfs(0, '');
4848

4949
return result;
5050
};
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
import { test, expect } from 'vitest';
22
import { isValidParenthesis } from './ValidParentheses';
33

4-
test("isValidParenthesis1", () => {
5-
const input = "()";
4+
test('isValidParenthesis1', () => {
5+
const input = '()';
66
expect(isValidParenthesis(input)).toBeTruthy();
77
});
88

9-
test("isValidParenthesis2", () => {
10-
const input = "()[]{}";
9+
test('isValidParenthesis2', () => {
10+
const input = '()[]{}';
1111
expect(isValidParenthesis(input)).toBeTruthy();
1212
});
1313

14-
test("isValidParenthesis3", () => {
15-
const input = "([)]";
14+
test('isValidParenthesis3', () => {
15+
const input = '([)]';
1616
expect(isValidParenthesis(input)).toBeFalsy();
1717
});

typescript/problem_0020/ValidParentheses.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@
1616

1717
const isValidParenthesis = (s: string): boolean => {
1818
const dict: { [key: string]: string } = {
19-
"(": ")",
20-
"{": "}",
21-
"[": "]",
19+
'(': ')',
20+
'{': '}',
21+
'[': ']',
2222
};
2323
const array: string[] = [];
2424

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { test, expect } from 'vitest';
22
import { generateParenthesis } from './GenerateParentheses';
33

4-
test("test1", () => {
4+
test('test1', () => {
55
const n = 3;
6-
const result = ["((()))", "(()())", "(())()", "()(())", "()()()"];
6+
const result = ['((()))', '(()())', '(())()', '()(())', '()()()'];
77
expect(generateParenthesis(n)).toStrictEqual(result);
88
});

0 commit comments

Comments
 (0)