Skip to content

Commit 4e6d8f0

Browse files
authored
Merge branch 'DaleStudy:main' into main
2 parents 845c93f + 6690735 commit 4e6d8f0

Some content is hidden

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

46 files changed

+1363
-5
lines changed

โ€Ž.github/labeler.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,8 @@ elixir:
5252
- changed-files:
5353
- any-glob-to-any-file:
5454
- "**/*.exs"
55+
56+
rust:
57+
- changed-files:
58+
- any-glob-to-any-file:
59+
- "**/*.rs"

โ€Ž.github/pull_request_template.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
11
## ๋‹ต์•ˆ ์ œ์ถœ ๋ฌธ์ œ
22

33
<!--
4-
์ž์‹ ์˜ ์ˆ˜์ค€์ด๋‚˜ ์ผ์ •์— ๋งž๊ฒŒ ๊ธˆ์ฃผ์— ํ‘ธ์‹œ๊ธฐ๋กœ ์ •ํ•œ ๋ฌธ์ œ๋“ค๋งŒ ๋‚˜์—ดํ•ด์ฃผ์„ธ์š”.
5-
์ฝ”๋“œ ๊ฒ€ํ† ์ž๋“ค์ด PR ์Šน์ธ ์—ฌ๋ถ€๋ฅผ ๊ฒฐ์ •ํ•  ๋•Œ ๋„์›€์ด ๋ฉ๋‹ˆ๋‹ค.
4+
์ž์‹ ์˜ ์ˆ˜์ค€์ด๋‚˜ ์ผ์ •์— ๋งž๊ฒŒ ๐Ÿ‘‰๊ธˆ์ฃผ์— ํ‘ธ์‹œ๊ธฐ๋กœ ์ •ํ•œ ๋ฌธ์ œ๋“ค๐Ÿ‘ˆ๋งŒ ๋‚˜์—ดํ•ด์ฃผ์„ธ์š”.
5+
๋ฆฌ๋ทฐ์–ด๋“ค์ด ๊ฒ€ํ† ์™€ PR ์Šน์ธ ์—ฌ๋ถ€๋ฅผ ๊ฒฐ์ •ํ•  ๋•Œ ํฐ ๋„์›€์ด ๋ฉ๋‹ˆ๋‹ค.
66
-->
77

88
- [ ] ๋ฌธ์ œ 1
99
- [ ] ๋ฌธ์ œ 2
1010
- [ ] ๋ฌธ์ œ 3
11+
<!-- - [ ] ๋ฌธ์ œ 4 ํ’€๊ณ ์‹ถ์ง€ ์•Š์€ ๋ฌธ์ œ๋Š” ์ด๋ ‡๊ฒŒ ์ฃผ์„์ฒ˜๋ฆฌ ํ•ด ์ฃผ์…”๋„ ์ข‹์•„์š” -->
1112

1213
## ์ฒดํฌ ๋ฆฌ์ŠคํŠธ
1314

14-
- [ ] PR์„ ํ”„๋กœ์ ํŠธ์— ์ถ”๊ฐ€ํ•˜๊ณ  Week๋ฅผ ํ˜„์žฌ ์ฃผ์ฐจ๋กœ ์„ค์ •ํ•ด์ฃผ์„ธ์š”.
15+
- [ ] ์šฐ์ธก ๋ฉ”๋‰ด์—์„œ PR์„ **Projects**์— ์ถ”๊ฐ€ํ•ด์ฃผ์„ธ์š”.
16+
- [ ] **Projects**์˜ ์˜ค๋ฅธ์ชฝ ๋ฒ„ํŠผ(โ–ผ)์„ ๋ˆŒ๋Ÿฌ ํ™•์žฅํ•œ ๋’ค, **Week**๋ฅผ ํ˜„์žฌ ์ฃผ์ฐจ๋กœ ์„ค์ •ํ•ด์ฃผ์„ธ์š”.
1517
- [ ] ๋ฐ”๋กœ ์•ž์— PR์„ ์—ด์–ด์ฃผ์‹  ๋ถ„์„ ์ฝ”๋“œ ๊ฒ€ํ† ์ž๋กœ ์ง€์ •ํ•ด์ฃผ์„ธ์š”.
16-
- [ ] ๋ฌธ์ œ๋ฅผ ๋ชจ๋‘ ํ‘ธ์‹œ๋ฉด ํ”„๋กœ์ ํŠธ์—์„œ Status๋ฅผ `In Review`๋กœ ์„ค์ •ํ•ด์ฃผ์„ธ์š”.
18+
- [ ] ๋ฌธ์ œ๋ฅผ ๋ชจ๋‘ ํ‘ธ์‹œ๋ฉด ํ”„๋กœ์ ํŠธ์—์„œ **Status**๋ฅผ `In Review`๋กœ ์„ค์ •ํ•ด์ฃผ์„ธ์š”.
1719
- [ ] ์ฝ”๋“œ ๊ฒ€ํ† ์ž 1๋ถ„ ์ด์ƒ์œผ๋กœ๋ถ€ํ„ฐ ์Šน์ธ์„ ๋ฐ›์œผ์…จ๋‹ค๋ฉด PR์„ ๋ณ‘ํ•ฉํ•ด์ฃผ์„ธ์š”.

โ€Ž.github/workflows/integration.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ jobs:
8585
- name: Check filename rules
8686
if: ${{ steps.pr-labels.outputs.has_maintenance != 'true' }}
8787
run: |
88-
files=$(git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.sha }} | tr -d '"')
88+
files=$(git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }} | tr -d '"')
8989
pr_author="${{ github.event.pull_request.user.login }}"
9090
success=true
9191
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
class Solution {
2+
/**
3+
* ์‹œ๊ฐ„ ๋ณต์žก๋„: O(N)
4+
* ๊ณต๊ฐ„ ๋ณต์žก๋„: O(N)
5+
*/
6+
public boolean containsDuplicate(int[] nums) {
7+
Set<Integer> set = new HashSet<>();
8+
9+
for (int num : nums) {
10+
if (set.contains(num)) return true;
11+
set.add(num);
12+
}
13+
14+
return false;
15+
}
16+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package leetcode_study
2+
3+
/**
4+
* Set ์ž๋ฃŒ ๊ตฌ์กฐ๋กœ ๋ณ€๊ฒฝ ํ›„ ์›์†Œ์˜ ๊ฐœ์ˆ˜๋ฅผ ๋น„๊ตํ•ด ๋ฌธ์ œ ํ•ด๊ฒฐ
5+
* ์‹œ๊ฐ„ ๋ณต์žก๋„ : O(n)
6+
* -> ๋ชจ๋“  Array์˜ ์›์†Œ๋ฅผ ์ˆœํšŒํ•ด์•ผํ•จ.
7+
* ๊ณต๊ฐ„ ๋ณต์žก๋„ : O(n)
8+
* -> IntArray์˜ ์š”์†Œ ๊ฐœ์ˆ˜์— ๋น„๋ก€ํ•˜์—ฌ ์ถ”๊ฐ€์ ์ธ ๊ณต๊ฐ„์ด ํ•„์š”ํ•จ.
9+
*/
10+
fun containsDuplicate(nums: IntArray): Boolean {
11+
val changeSet = nums.toSet()
12+
return changeSet.size != nums.size
13+
}

โ€Žcontains-duplicate/Gotprgmer.java

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import java.util.HashSet;
2+
import java.util.Set;
3+
4+
class SolutionGotprgmer {
5+
// ํ•ด๋‹น ๋ฌธ์ œ๋Š” ์–ด๋А ํ•œ ์ˆซ์ž๊ฐ€ 2๊ฐœ์ด์ƒ ์กด์žฌํ•  ๊ฒฝ์šฐ true๋ฅผ ๊ทธ๋ ‡์ง€ ์•Š์„ ๊ฒฝ์šฐ, false๋ฅผ ๋ฐ˜ํ™˜ํ•˜๋Š” ๋ฌธ์ œ์ด๋‹ค.
6+
// set์„ ์‚ฌ์šฉํ•ด์„œ set์— ์ด๋ฏธ ๊ฐ’์ด ์กด์žฌํ•œ๋‹ค๋ฉด ๊ฐœ์ˆ˜๊ฐ€ 2 ์ด์ƒ์ด๋ฏ€๋กœ true ๊ทธ๋ ‡์ง€ ์•Š์œผ๋ฉด false๋ฅผ ์ถœ๋ ฅํ•œ๋‹ค.
7+
8+
// ๊ฐ ์ˆซ์ž๋“ค์„ ์ €์žฅํ•ด์„œ set์œผ๋กœ ๊ด€๋ฆฌ -> distinctNums
9+
// nums์˜ ๊ฐ ์ˆซ์ž์ธ checkNum์„ distinctNums์— ๋„ฃ์–ด์ค€๋‹ค.
10+
// ๋งŒ์•ฝ checkNum์ด ์ด๋ฏธ distinctNums์— ์กด์žฌํ•œ๋‹ค๋ฉด ans๋ฅผ true๋กœ ๋งŒ๋“ค์–ด์ฃผ๊ณ  ๋‹ต์„ ์ถœ๋ ฅํ•œ๋‹ค.
11+
12+
13+
// ์‹œ๊ฐ„๋ณต์žก๋„ -> O(n)
14+
// ๊ณต๊ฐ„๋ณต์žก๋„ -> O(n)
15+
static Set<Integer> distinctNums;
16+
public boolean containsDuplicate(int[] nums) {
17+
distinctNums = new HashSet<>();
18+
boolean ans = false;
19+
for (int checkNum : nums) {
20+
if (distinctNums.contains(checkNum)) {
21+
ans = true;
22+
break;
23+
};
24+
distinctNums.add(checkNum);
25+
}
26+
return ans;
27+
}
28+
29+
30+
}

โ€Žcontains-duplicate/JisooPyo.kt

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
package leetcode_study
2+
3+
import io.kotest.matchers.shouldBe
4+
import org.junit.jupiter.api.Test
5+
6+
/**
7+
* Leetcode
8+
* 217. Contains Duplicate
9+
* Easy
10+
*/
11+
class ContainsDuplicate {
12+
/**
13+
* Runtime: 17 ms(Beats: 80.99 %)
14+
* Time Complexity: O(n)
15+
* - ๋ฐฐ์—ด ์ˆœํšŒ
16+
*
17+
* Memory: 50.63 MB(Beats: 70.32 %)
18+
* Space Complexity: O(n)
19+
* - HashSet์— ์ตœ์•…์˜ ๊ฒฝ์šฐ ๋ฐฐ์—ด ์›์†Œ ๋ชจ๋‘ ์ €์žฅ
20+
*/
21+
fun containsDuplicate(nums: IntArray): Boolean {
22+
val set = hashSetOf<Int>()
23+
for (i in nums) {
24+
if (set.contains(i)) {
25+
return true
26+
}
27+
set.add(i)
28+
}
29+
return false
30+
}
31+
32+
@Test
33+
fun test() {
34+
containsDuplicate(intArrayOf(1, 2, 3, 1)) shouldBe true
35+
containsDuplicate(intArrayOf(1, 2, 3, 4)) shouldBe false
36+
containsDuplicate(intArrayOf(1, 1, 1, 3, 3, 4, 3, 2, 4, 2)) shouldBe true
37+
}
38+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Time complexity, O(n)
2+
// Space complexity, O(n)
3+
// ํ’€์ด
4+
// nums ๋ฐฐ์—ด์„ ์ˆœํšŒํ•˜๋ฉด์„œ hashMap์— num์„ key๋กœ, ์กด์žฌ ์—ฌ๋ถ€๋ฅผ value๋กœ ์ €์žฅํ•œ๋‹ค.
5+
// ๋งŒ์•ฝ ์ด๋ฏธ ์กด์žฌํ•˜๋Š” key๋ผ๋ฉด true๋ฅผ ๋ฐ˜ํ™˜ํ•˜๊ณ , ์ˆœํšŒ๋ฅผ ์ „๋ถ€ ํ–ˆ๋Š”๋ฐ๋„ ์ค‘๋ณต์ด ์—†๋‹ค๋ฉด false๋ฅผ ๋ฐ˜ํ™˜ํ•œ๋‹ค.
6+
func containsDuplicate(nums []int) bool {
7+
hashMap := map[int]bool{}
8+
for _, num := range nums {
9+
if hashMap[num] {
10+
return true
11+
}
12+
hashMap[num] = true
13+
}
14+
return false
15+
}

โ€Žcontains-duplicate/dusunax.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
'''
2+
# Leetcode 217. Contains Duplicate
3+
4+
use set to store distinct elements ๐Ÿ—‚๏ธ
5+
6+
## Time and Space Complexity
7+
8+
```
9+
TC: O(n)
10+
SC: O(n)
11+
```
12+
13+
### TC is O(n):
14+
- iterating through the list just once to convert it to a set.
15+
16+
### SC is O(n):
17+
- creating a set to store the distinct elements of the list.
18+
'''
19+
20+
class Solution:
21+
def containsDuplicate(self, nums: List[int]) -> bool:
22+
return len(nums) != len(set(nums))
23+

โ€Žcontains-duplicate/jeldo.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
class Solution:
2+
# O(n)
3+
def containsDuplicate(self, nums: list[int]) -> bool:
4+
return len(nums) != len(set(nums)) # O(n)

0 commit comments

Comments
ย (0)