Skip to content

Commit bd8eb04

Browse files
committed
fix: lint
1 parent 00d02f2 commit bd8eb04

File tree

3 files changed

+41
-41
lines changed

3 files changed

+41
-41
lines changed

contains-duplicate/choidabom.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
11
// https://leetcode.com/problems/contains-duplicate/description/
22

33
// TC: O(n)
4-
// SC: O(n)
4+
// SC: O(n)
55

66
function containsDuplicate(nums: number[]): boolean {
7-
const set = new Set(nums)
8-
return set.size !== nums.length
9-
};
7+
const set = new Set(nums);
8+
return set.size !== nums.length;
9+
}
1010

1111
function containsDuplicate(nums: number[]): boolean {
12-
const set = new Set()
12+
const set = new Set();
1313

14-
for (const num of nums){
15-
if (set.has(num)){
16-
return true
17-
}
18-
set.add(num)
14+
for (const num of nums) {
15+
if (set.has(num)) {
16+
return true;
1917
}
18+
set.add(num);
19+
}
2020

21-
return false
21+
return false;
2222
}
2323

24-
console.log(containsDuplicate([1,1,1,3,3,4,3,2,4,2]))
24+
console.log(containsDuplicate([1, 1, 1, 3, 3, 4, 3, 2, 4, 2]));

top-k-frequent-elements/choidabom.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,16 @@
44
// SC: O(n)
55

66
function topKFrequent(nums: number[], k: number): number[] {
7-
const map = new Map()
7+
const map = new Map();
88

9-
for (const num of nums) {
10-
if (map.has(num)){
11-
map.set(num, map.get(num) + 1)
12-
} else {
13-
map.set(num, 1)
14-
}
9+
for (const num of nums) {
10+
if (map.has(num)) {
11+
map.set(num, map.get(num) + 1);
12+
} else {
13+
map.set(num, 1);
1514
}
15+
}
1616

17-
const sortedMap = [...map].sort((a, b)=> b[1]- a[1])
18-
return sortedMap.splice(0, k).map((item)=> item[0])
19-
};
17+
const sortedMap = [...map].sort((a, b) => b[1] - a[1]);
18+
return sortedMap.splice(0, k).map((item) => item[0]);
19+
}

two-sum/choidabom.ts

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,33 +4,33 @@
44
// SC: O(1)
55

66
function twoSum(nums: number[], target: number): number[] {
7-
for (let i = 0; i < nums.length; i++) {
8-
for (let j = i + 1; j < nums.length; j++){
9-
if (nums[i] + nums[j] === target){
10-
return [i, j]
11-
}
7+
for (let i = 0; i < nums.length; i++) {
8+
for (let j = i + 1; j < nums.length; j++) {
9+
if (nums[i] + nums[j] === target) {
10+
return [i, j];
1211
}
1312
}
14-
return []
15-
};
13+
}
14+
return [];
15+
}
1616

1717
// TC: O(n)
1818
// SC: O(n)
1919

2020
function twoSum(nums: number[], target: number): number[] {
21-
const map = new Map()
21+
const map = new Map();
2222

23-
for (let i = 0; i < nums.length; i++) {
24-
const num = nums[i]
25-
const diff = target - num
23+
for (let i = 0; i < nums.length; i++) {
24+
const num = nums[i];
25+
const diff = target - num;
2626

27-
if (map.has(diff)) {
28-
return [i, map.get(diff)]
29-
} else {
30-
map.set(num, i)
31-
}
27+
if (map.has(diff)) {
28+
return [i, map.get(diff)];
29+
} else {
30+
map.set(num, i);
3231
}
33-
return []
34-
};
32+
}
33+
return [];
34+
}
3535

36-
console.log(twoSum([2,7,11,15], 9))
36+
console.log(twoSum([2, 7, 11, 15], 9));

0 commit comments

Comments
 (0)