Skip to content

Commit 53eef2b

Browse files
authored
Merge branch 'DaleStudy:main' into main
2 parents 7728ffa + 36cfe67 commit 53eef2b

Some content is hidden

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

92 files changed

+2327
-5
lines changed

.github/workflows/integration.yaml

Lines changed: 47 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,19 @@ jobs:
1515
- name: Get PR labels
1616
id: pr-labels
1717
run: |
18+
echo "🔍 PR 번호: ${{ github.event.pull_request.number }}"
1819
pr_number="${{ github.event.pull_request.number }}"
20+
21+
echo "📋 PR 라벨 조회 중..."
1922
labels_json=$(gh pr view $pr_number --json labels -q '.labels[].name')
23+
echo "확인된 라벨: $labels_json"
24+
2025
if [ -n "$labels_json" ]; then
21-
echo "has_maintenance=$(echo $labels_json | grep -q 'maintenance' && echo 'true' || echo 'false')" >> $GITHUB_OUTPUT
26+
has_maintenance=$(echo $labels_json | grep -q 'maintenance' && echo 'true' || echo 'false')
27+
echo "maintenance 라벨 포함 여부: $has_maintenance"
28+
echo "has_maintenance=$has_maintenance" >> $GITHUB_OUTPUT
2229
else
30+
echo "maintenance 라벨이 없는 PR입니다. 파일명 규칙 검사를 진행합니다."
2331
echo "has_maintenance=false" >> $GITHUB_OUTPUT
2432
fi
2533
env:
@@ -28,35 +36,46 @@ jobs:
2836
# 줄바꿈 체크
2937
- name: Check for missing end line breaks
3038
run: |
31-
# 따옴표를 제거하고 파일 목록 가져오기
39+
echo "🔍 줄바꿈 검사 시작"
40+
echo "기준 커밋: ${{ github.event.pull_request.base.sha }}"
41+
echo "현재 커밋: ${{ github.sha }}"
42+
3243
files=$(git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.sha }} | tr -d '"')
3344
success=true
3445
35-
echo "변경된 파일 목록:"
46+
echo "📝 변경된 파일 목록:"
3647
echo "$files"
3748
3849
echo "## 줄바꿈 누락 파일" >> $GITHUB_STEP_SUMMARY
3950
for file in $files; do
51+
echo "검사 중: $file"
4052
if [ -s "$file" ] && [ "$(tail -c 1 $file | wc -l)" -eq 0 ]; then
41-
echo "발견된 줄바꿈 누락: $file"
53+
echo " 줄바꿈 누락: $file"
4254
echo "- $file" >> $GITHUB_STEP_SUMMARY
4355
success=false
56+
else
57+
echo "✅ 정상: $file"
4458
fi
4559
done
4660
4761
if [ "$success" = false ]; then
62+
echo "⚠️ 줄바꿈 검사 실패"
4863
echo -e "\n:warning: 파일 끝의 누락된 줄바꿈을 추가해 주세요." >> $GITHUB_STEP_SUMMARY
4964
exit 1
65+
else
66+
echo "✅ 모든 파일의 줄바꿈 정상"
5067
fi
5168
5269
# 제어문자 체크
5370
- name: Check for control characters in filenames
5471
run: |
72+
echo "🔍 파일명 제어문자 검사 시작"
5573
files=$(git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.sha }} | tr -d '"')
5674
success=true
5775
5876
echo "## 제어문자가 포함된 파일명" >> $GITHUB_STEP_SUMMARY
5977
for file in $files; do
78+
echo "검사 중: $file"
6079
# basename으로 파일명만 추출하고 따옴표 제거
6180
filename=$(basename "$file" | tr -d '"')
6281
@@ -71,43 +90,66 @@ jobs:
7190
7291
# 이스케이프 시퀀스 체크
7392
[[ "$filename" =~ (\\[0-7]{1,3}|\\x[0-9a-fA-F]{1,2}) ]]; then
93+
echo "❌ 제어문자 발견: $file"
7494
echo "- $file (제어문자 포함)" >> $GITHUB_STEP_SUMMARY
7595
success=false
96+
else
97+
echo "✅ 정상: $file"
7698
fi
7799
done
78100
79101
if [ "$success" = false ]; then
102+
echo "⚠️ 제어문자 검사 실패"
80103
echo -e "\n:warning: 파일명에서 제어문자를 제거해 주세요." >> $GITHUB_STEP_SUMMARY
81104
exit 1
105+
else
106+
echo "✅ 모든 파일명이 제어문자 없이 정상"
82107
fi
83108
84109
# 파일명 규칙 체크 - maintenance 라벨이 없는 경우에만 실행
85110
- name: Check filename rules
86111
if: ${{ steps.pr-labels.outputs.has_maintenance != 'true' }}
87112
run: |
88-
files=$(git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }} | tr -d '"')
113+
echo "🔍 파일명 규칙 검사 시작"
114+
echo "PR 작성자: ${{ github.event.pull_request.user.login }}"
115+
116+
# PR의 공통 조상 커밋을 찾아서 merge base로 설정
117+
merge_base=$(git merge-base ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }})
118+
echo "Merge base 커밋: $merge_base"
119+
120+
files=$(git diff --name-only $merge_base ${{ github.event.pull_request.head.sha }} | tr -d '"')
89121
pr_author="${{ github.event.pull_request.user.login }}"
90122
success=true
91123
124+
echo "📝 검사할 파일 목록:"
125+
echo "$files"
126+
92127
echo "## 파일명 규칙 위반" >> $GITHUB_STEP_SUMMARY
93128
for file in $files; do
94129
if [ -f "$file" ]; then
95130
131+
echo "검사 중: $file"
96132
# 파일명만 추출 (경로 제외)
97133
filename=$(basename "$file")
98134
99135
# 파일명이 GitHub계정명인지 확인
100136
shopt -s nocasematch
101137
if [[ ! "$filename" = "$pr_author"* ]]; then
138+
echo "❌ 규칙 위반: $file"
102139
echo "- $file" >> $GITHUB_STEP_SUMMARY
103140
success=false
141+
else
142+
echo "✅ 정상: $file"
104143
fi
105144
fi
106145
done
107146
108147
if [ "$success" = false ]; then
148+
echo "⚠️ 파일명 규칙 검사 실패"
109149
echo -e "\n:warning: 파일명은 반드시 'GitHub계정명' 또는 'GitHub계정명-xxx' 형식으로 해주셔야 합니다. (예: ${pr_author}.ts, ${pr_author}-1.ts, ${pr_author}-2.ts)" >> $GITHUB_STEP_SUMMARY
110150
exit 1
151+
else
152+
echo "✅ 모든 파일명이 규칙에 맞게 정상"
111153
fi
112154
env:
113155
GH_TOKEN: ${{ github.token }}

3sum/easyone-jwlee.go

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
// 풀이
2+
// 배열을 정렬하고
3+
// two pointer 사용
4+
5+
// TC
6+
// 정렬 O(nlogn) + Two pointer 이중 루프 O(n^2) = O(n^2)
7+
8+
// SC
9+
// Go의 sort.Ints()는 TimSort를 사용.
10+
// Merge Sort와 Insertion Sort의 조합으로 동작.
11+
// 정렬 O(n) + Two pointer O(1) + 결과 배열 O(n) = O(n)
12+
13+
func threeSum(nums []int) [][]int {
14+
result := [][]int{}
15+
sort.Ints(nums) // nums를 정렬
16+
17+
for i := 0; i < len(nums)-2; i++ {
18+
if i > 0 && nums[i] == nums[i-1] {
19+
continue // 중복된 값 건너뜀
20+
}
21+
22+
left, right := i+1, len(nums)-1
23+
for left < right {
24+
sum := nums[i] + nums[left] + nums[right]
25+
if sum == 0 {
26+
result = append(result, []int{nums[i], nums[left], nums[right]})
27+
left++
28+
right--
29+
30+
// 중복 제거
31+
for left < right && nums[left] == nums[left-1] {
32+
left++
33+
}
34+
for left < right && nums[right] == nums[right+1] {
35+
right--
36+
}
37+
} else if sum < 0 {
38+
left++
39+
} else {
40+
right--
41+
}
42+
}
43+
}
44+
45+
return result
46+
}

climbing-stairs/easyone-jwlee.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// 풀이
2+
// 1 일 때, 가능한 step은 1 -> 1가지
3+
// 2 일 때, 가능한 step은 1 1, 2 -> 2가지
4+
// 3 일 때, 가능한 step은 1 1 1, 1 2, 2 1 -> 3가지
5+
// n 일 때, 가능한 stop은 n-1의 가짓수에 1이 붙고, n-2의 가짓수에 2가 붙는다.
6+
7+
// TC
8+
// O(n)
9+
10+
// SC
11+
// int타입 변수만 사용해서 O(1)
12+
13+
func climbStairs(n int) int {
14+
if n <= 2 {
15+
return n
16+
}
17+
prev := 1 // climb1
18+
curr := 2 // climb2
19+
for i := 3; i <= n; i++ {
20+
prev, curr = curr, (curr + prev)
21+
}
22+
return curr
23+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
// 풀이
2+
// preorder[0]이 제일 꼭대기
3+
// preorder 배열의 root index, inorder 배열의 시작, inorder 배열의 끝
4+
// 위의 세가지를 parameter로 받는 재귀함수를 만들어서
5+
// 왼쪽 서브트리, 오른쪽 서브트리를 순회
6+
7+
// TC
8+
// map 만들기 O(n) + 재귀함수는 각 노드를 딱 한번씩만 방문하므로 O(n) = O(n)
9+
10+
// SC
11+
// map O(n) + 재귀함수 최악의 경우 한쪽으로만 노드가 이어지는 경우 O(n) = O(n)
12+
13+
func buildTree(preorder []int, inorder []int) *TreeNode {
14+
inorderMap := make(map[int]int)
15+
for i, n := range inorder {
16+
inorderMap[n] = i
17+
}
18+
19+
var recursive func(rootIndex, inStart, inEnd int) *TreeNode
20+
recursive = func(rootIndex, inStart, inEnd int) *TreeNode {
21+
if rootIndex >= len(preorder) || inStart > inEnd {
22+
return nil
23+
}
24+
rootVal := preorder[rootIndex]
25+
rootInorderIndex := inorderMap[rootVal]
26+
27+
result := &TreeNode{
28+
Val: rootVal,
29+
}
30+
31+
leftSize := rootInorderIndex - inStart
32+
33+
result.Left = recursive(rootIndex+1, inStart, rootInorderIndex-1)
34+
result.Right = recursive(rootIndex+1+leftSize, rootInorderIndex+1, inEnd)
35+
36+
return result
37+
}
38+
39+
return recursive(0, 0, len(inorder)-1)
40+
}

contains-duplicate/EstherKim97.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Given an integer array nums, return true if any value appears at least twice in the array, and return false if every element is distinct.
2+
3+
def containsDuplicate(nums):
4+
seen = set()
5+
for num in nums:
6+
if num in seen:
7+
return True
8+
seen.add(num)
9+
return False
10+

contains-duplicate/Jeehay28.js

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

contains-duplicate/KwonNayeon.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
"""
2+
Title: 217. Contains Duplicate
3+
Link: https://leetcode.com/problems/contains-duplicate/
4+
5+
Summary:
6+
- 주어진 배열 `nums`에서 어떤 값이 한 번 이상 등장하면 True를 반환하고, 배열의 모든 값이 유일한 경우에는 False를 반환함
7+
- Input: `nums = [1,2,3,1]`
8+
- Output: `True`
9+
10+
Conditions:
11+
- 중복이 있으면: 배열에서 적어도 하나의 값이 두 번 이상 등장하면 `True` 반환
12+
- 중복이 없으면: 배열의 모든 값이 유일하면 `False` 반환
13+
"""
14+
15+
"""
16+
First Try
17+
Time Complexity:
18+
- O(n) * O(n) = O(n^2): `for` 루프에서 `nums.count(i)`를 호출할 때마다 리스트를 순회하므로, 전체 시간 복잡도는 `O(n^2)`
19+
"""
20+
class Solution:
21+
def containsDuplicate(self, nums: List[int]) -> bool:
22+
for i in nums:
23+
if nums.count(i) > 1:
24+
return True
25+
return False
26+
27+
"""
28+
Second Try (set를 활용하여 이미 본 요소를 효율적으로 추적하는 방법)
29+
Time Complexity:
30+
- O(n): `for` 루프에서 각 숫자에 대해 `in` 연산과 `add` 연산이 상수 시간 O(1)으로 처리되므로, 전체 시간 복잡도는 O(n)
31+
"""
32+
class Solution:
33+
def containsDuplicate(self, nums: List[int]) -> bool:
34+
seen = set()
35+
for i in nums:
36+
if i in seen:
37+
return True
38+
seen.add(i)
39+
return False

contains-duplicate/Totschka.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// https://leetcode.com/problems/contains-duplicate/
2+
function containsDuplicate(nums: number[]): boolean {
3+
const counter = {};
4+
for (const n of nums) {
5+
if (!counter[n]) {
6+
counter[n] = 1;
7+
} else {
8+
return true;
9+
}
10+
}
11+
return false;
12+
}

contains-duplicate/Yjason-K.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/**
2+
* Set 자료구조를 사용하여 중복 확인 (시간 복잡도: O(n) )
3+
* @param nums 중복 검사할 숫자 배열
4+
* @returns boolean 중복 여부
5+
*/
6+
7+
function containsDuplicate(nums: number[]): boolean {
8+
let unique: Set<number> = new Set([]);
9+
for (const num of nums) {
10+
if (unique.has(num)) {
11+
return true
12+
} else {
13+
unique.add(num)
14+
}
15+
}
16+
return false;
17+
};
18+

contains-duplicate/choidabom.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/**
2+
* Runtime: 17ms, Memory: 63.18MB
3+
*
4+
* Time Complexity: O(n)
5+
* - Array to Set takes O(n)
6+
* - Compare Set size and array length takes O(1)
7+
* Space Complexity: O(n)
8+
* - Space for Set : O(n)
9+
*/
10+
11+
/**
12+
* @param {number[]} nums
13+
* @return {boolean}
14+
*/
15+
var containsDuplicate = function(nums) {
16+
return new Set(nums).size !== nums.length
17+
};

0 commit comments

Comments
 (0)