Skip to content

Commit 4ed4d3c

Browse files
authored
Merge branch 'DaleStudy:main' into main
2 parents ac0d67a + 4eda421 commit 4ed4d3c

File tree

142 files changed

+4316
-2
lines changed

Some content is hidden

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

142 files changed

+4316
-2
lines changed

.github/workflows/integration.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
name: 🔄 Integration
2+
3+
on:
4+
pull_request:
5+
6+
jobs:
7+
linelint:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/checkout@v4
11+
- uses: fernandrone/[email protected]

.linelint.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# 'true' will fix files
2+
autofix: false
3+
4+
# list of paths to ignore, uses gitignore syntaxes (executes before any rule)
5+
ignore:
6+
- "*.md"
7+
8+
rules:
9+
# checks if file ends in a newline character
10+
end-of-file:
11+
# set to true to enable this rule
12+
enable: true
13+
14+
# set to true to disable autofix (if enabled globally)
15+
disable-autofix: false
16+
17+
# if true also checks if file ends in a single newline character
18+
single-new-line: false

binary-tree-level-order-traversal/WhiteHyun.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,4 +104,4 @@ class Solution {
104104

105105
return array
106106
}
107-
}
107+
}

contains-duplicate/0-chan.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/**
2+
* time complexity : O(n)
3+
* space complexity : O(n)
4+
*/
5+
function containsDuplicate(nums: number[]): boolean {
6+
const hasDuplicate = new Set(nums).size !== nums.length;
7+
return hasDuplicate;
8+
};

contains-duplicate/EGON.py

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
from unittest import TestCase, main
2+
from typing import List
3+
from collections import Counter
4+
5+
6+
class Solution:
7+
def containsDuplicate(self, nums: List[int]) -> bool:
8+
return self.solve_3(nums=nums)
9+
10+
"""
11+
Runtime: 412 ms (Beats 75.17%)
12+
Analyze Complexity: O(n)
13+
Memory: 31.92 MB (Beats 45.93%)
14+
"""
15+
def solve_1(self, nums: List[int]) -> bool:
16+
return len(nums) != len(set(nums))
17+
18+
"""
19+
Runtime: 423 ms (Beats 39.66%)
20+
Analyze Complexity: O(n)
21+
Memory: 34.54 MB (Beats 14.97%)
22+
"""
23+
def solve_2(self, nums: List[int]) -> bool:
24+
counter = {}
25+
for num in nums:
26+
if num in counter:
27+
return True
28+
else:
29+
counter[num] = True
30+
else:
31+
return False
32+
33+
"""
34+
Runtime: 441 ms (Beats 16.59%)
35+
Analyze Complexity: O(n)
36+
Memory: 34.57 MB (Beats 14.97%)
37+
"""
38+
def solve_3(self, nums: List[int]) -> bool:
39+
return Counter(nums).most_common(1)[0][1] > 1
40+
41+
42+
class _LeetCodeTCs(TestCase):
43+
def test_1(self):
44+
nums = [1, 2, 3, 1]
45+
output = True
46+
self.assertEqual(Solution.containsDuplicate(Solution(), nums=nums), output)
47+
48+
def test_2(self):
49+
nums = [1, 2, 3, 4]
50+
output = False
51+
self.assertEqual(Solution.containsDuplicate(Solution(), nums=nums), output)
52+
53+
def test_3(self):
54+
nums = [1, 1, 1, 3, 3, 4, 3, 2, 4, 2]
55+
output = True
56+
self.assertEqual(Solution.containsDuplicate(Solution(), nums=nums), output)
57+
58+
59+
if __name__ == '__main__':
60+
main()

contains-duplicate/EGON.swift

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import Foundation
2+
3+
class Solution {
4+
func containsDuplicate(_ nums: [Int]) -> Bool {
5+
return solve_2(nums)
6+
}
7+
8+
/*
9+
Runtime: 246 ms (Beats 68.44%)
10+
Analyze Complexity: O(n)
11+
Memory: 19.94 MB (Beats 76.01%)
12+
*/
13+
func solve_1(_ nums: [Int]) -> Bool {
14+
return nums.count != Set(nums).count
15+
}
16+
17+
/*
18+
Runtime: 240 ms (Beats 90.56%)
19+
Analyze Complexity: O(n)
20+
Memory: 22.56 MB (Beats 33.43%)
21+
*/
22+
func solve_2(_ nums: [Int]) -> Bool {
23+
var counter: [Int: Bool] = [:]
24+
for num in nums {
25+
if counter[num] != nil {
26+
return true
27+
} else {
28+
counter[num] = true
29+
}
30+
}
31+
32+
return false
33+
}
34+
}

contains-duplicate/GUMUNYEONG.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/**
2+
* @param {number[]} nums
3+
* @return {boolean}
4+
*/
5+
var containsDuplicate = function (nums) {
6+
const setObj = new Set(nums);
7+
8+
const diff = !(nums.length === setObj.size);
9+
10+
return diff;
11+
};
12+
13+
// TC: O(n)
14+
// SC: O(n)

contains-duplicate/HC-kang.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/**
2+
217. Contains Duplicate
3+
4+
Example 1:
5+
Input: nums = [1,2,3,1]
6+
Output: true
7+
8+
Example 2:
9+
Input: nums = [1,2,3,4]
10+
Output: false
11+
12+
Example 3:
13+
Input: nums = [1,1,1,3,3,4,3,2,4,2]
14+
Output: true
15+
*/
16+
17+
// Time complexity: O(n)
18+
// Space complexity: O(n)
19+
function containsDuplicate(nums: number[]): boolean {
20+
return nums.length !== new Set(nums).size;
21+
}

contains-duplicate/Raft.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
class Solution:
2+
def containsDuplicate(self, nums: List[int]) -> bool:
3+
appeared = defaultdict(int)
4+
for n in nums:
5+
if appeared[n] > 0:
6+
return True
7+
appeared[n] += 1
8+
9+
return False
10+
# T: O(n)
11+
# S: O(n)
12+

contains-duplicate/TonyKim9401.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
class Solution {
2+
public boolean containsDuplicate(int[] nums) {
3+
// HashSet O(n)
4+
/*
5+
Set<Integer> set = new HashSet();
6+
for (int num : nums) set.add(num);
7+
return set.size() != nums.length;
8+
*/
9+
10+
// dupl value O(n log n)
11+
Arrays.sort(nums);
12+
for (int i = 0; i < nums.length - 1; i++) {
13+
if (nums[i] == nums[i + 1]) return true;
14+
}
15+
return false;
16+
}
17+
}

0 commit comments

Comments
 (0)