Skip to content

Commit 5487b35

Browse files
authored
Merge branch 'DaleStudy:main' into main
2 parents a41297f + 575eb87 commit 5487b35

File tree

134 files changed

+4047
-5
lines changed

Some content is hidden

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

134 files changed

+4047
-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

contains-duplicate/5YoonCheol.java

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+
}

contains-duplicate/Chaedie.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
2+
3+
'''
4+
풀이:
5+
중복된 요소가 있는지 찾는 문제입니다.
6+
7+
hash set 으로 중복을 제거하고
8+
기존 nums 의 길이와 중복 제거된 nums_set 의 길이가 같은지 return 했습니다.
9+
10+
시간 복잡도:
11+
O(n) - has set 을 만드는 시간
12+
13+
공간 복잡도:
14+
O(n) - n개의 요소를 set에 담기 때문
15+
'''
16+
17+
18+
class Solution:
19+
def containsDuplicate(self, nums: List[int]) -> bool:
20+
nums_set = set(nums)
21+
return len(nums_set) != len(nums)
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/GangBean.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import java.util.Arrays;
2+
import java.util.stream.Collectors;
3+
4+
class Solution {
5+
public boolean containsDuplicate(int[] nums) {
6+
/***
7+
compare length of array and length of set.
8+
O(n) given that n is length of array nums
9+
*/
10+
return nums.length > Arrays.stream(nums).boxed().collect(Collectors.toSet()).size();
11+
}
12+
}

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/HerrineKim.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// 시간복잡도: O(n)
2+
3+
/**
4+
* @param {number[]} nums
5+
* @return {boolean}
6+
*/
7+
var containsDuplicate = function (nums) {
8+
const seen = new Set();
9+
for (let num of nums) {
10+
if (seen.has(num)) {
11+
return true; // 중복 발견
12+
}
13+
seen.add(num);
14+
}
15+
return false; // 모든 요소가 고유
16+
};
17+

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+
}

0 commit comments

Comments
 (0)