Skip to content

Commit 2d466a8

Browse files
authored
Merge branch 'DaleStudy:main' into main
2 parents a01d15d + 3854db0 commit 2d466a8

File tree

264 files changed

+7411
-9
lines changed

Some content is hidden

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

264 files changed

+7411
-9
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: 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/GangBean.java

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
class Solution {
2+
public List<List<Integer>> threeSum(int[] nums) {
3+
/**
4+
1. understanding
5+
- integer array nums, find the whole combination of 3 nums, and the sum of the 3 nums equal to 0. And don't allow reusing same indiced number(but can duplicate in value)
6+
2. solve strategy
7+
- brute force
8+
- in every combination, validate sum of the nums equal to 0
9+
- but it can take O(N^3) times where N is the length of input array, and given that the N can be 3000 at most(3 * 10^3), time can be 27 * 10^9, which takes too long...
10+
- sort and two pointers
11+
- sort nums in ascending order, so move the left pointer to right means the sum of window is getting bigger.
12+
- and mid pointer set to left + 1 index
13+
- if sum of pointers is less than 0, then move mid pointer to right, until the sum is bigger than 0, and while processing them, if the sum of pointers is 0, then add the combination to the return list.
14+
- [-4, -1, -1, 0, 1, 2]:
15+
16+
3. complexity
17+
- time: O(N^2) -> each left pointer, you can search at most N-1, and left pointer's range is [0, N-1), so the max length is N-1 for left index pointer.
18+
- space: O(1) -> no extra space is needed
19+
*/
20+
// 0. assign return variable Set
21+
Set<List<Integer>> answer = new HashSet<>();
22+
23+
// 1. sort the num array in ascending order
24+
Arrays.sort(nums); // O(NlogN)
25+
// Arrays.stream(nums).forEach(System.out::println);
26+
27+
// 3. move the mid pointer from left to right to find the combination of which's sum is 0, and if the sum is over 0, and then move right pointer to the left. else if the sum is under 0, then move left pointer to right direction.
28+
for (int left = 0; left < nums.length - 1; left++) {
29+
int mid = left + 1;
30+
int right = nums.length - 1;
31+
while (mid < right) {
32+
// System.out.println(String.format("%d,%d,%d", nums[left], nums[mid], nums[right]));
33+
int sum = nums[left] + nums[mid] + nums[right];
34+
if (sum > 0) {
35+
right--;
36+
} else if (sum == 0) {
37+
answer.add(List.of(nums[left], nums[mid], nums[right]));
38+
right--;
39+
} else {
40+
mid++;
41+
}
42+
}
43+
}
44+
45+
return new ArrayList<>(answer);
46+
}
47+
}
48+

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/GangBean.java

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
class Solution {
2+
public int climbStairs(int n) {
3+
/**
4+
1. Understanding
5+
- return the count of ways to climb up to top
6+
- way means the sequence of step count
7+
- each state, there can be 2 ways. first climb 1 step, second climb 2 step
8+
2. solve strategy
9+
- assume the count of ways to climb up to K th stairs is C[K].
10+
- then, C[0] = 1, C[1] = 1, C[2] = 2(because, you can up to 2nd stair from 0th stair and also from 1st stair.)
11+
- and C[3] = C[2] + C[1], C[4] = C[3] + C[2], ... etc...
12+
- so we can fomulate C[k] = C[k-1] + C[k-2]
13+
- iterate over 0 to n, you can caculate C[k].
14+
- and finally return C[n] is the answer.
15+
16+
3. complexity
17+
- I answer to this part, along with coding upon each line description.
18+
*/
19+
20+
// 1. create array to demonstrate each stairs way count to reach that position.
21+
// the maximun step count is 45, so maybe there is over 2^32(approximately 2 billion; so i worry about the overflow), I assign long type array. Oh.. but i catch that return type of this method is integer, so i can assume that maximum value is under integer range. So, assign as integer.
22+
int[] c = new int[n + 1]; // the extra plus 1 means 0th stair state
23+
// space complexity: O(n)
24+
for (int stair = 0; stair <= n; stair++) { // time complexity O(n)
25+
if (stair <= 1) {
26+
c[stair] = 1; // O(1)
27+
continue;
28+
}
29+
c[stair] = c[stair-1] + c[stair-2]; // O(1)
30+
}
31+
32+
return c[n];
33+
}
34+
}
35+

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: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
/**
2+
* Definition for a binary tree node.
3+
* public class TreeNode {
4+
* int val;
5+
* TreeNode left;
6+
* TreeNode right;
7+
* TreeNode() {}
8+
* TreeNode(int val) { this.val = val; }
9+
* TreeNode(int val, TreeNode left, TreeNode right) {
10+
* this.val = val;
11+
* this.left = left;
12+
* this.right = right;
13+
* }
14+
* }
15+
*/
16+
class Solution {
17+
public TreeNode buildTree(int[] preorder, int[] inorder) {
18+
/**
19+
1. understanding
20+
- preorder: mid -> left -> right
21+
- inorder: left -> mid -> right
22+
- so, first element of the preorder array is always mid node.
23+
- if the idx of inorder's 1st depth mid node is k, then inorder[0:k-1] is the left tree part array. And also, preorder[k:] is the right tree part.
24+
2. strategy
25+
- find the inorder's mid node idx, and then split left tree part and right part, buildTree with each preorder and inorder part.
26+
27+
3. complexity
28+
- time: O(N^2)
29+
- space: O(N^2)
30+
*/
31+
if (preorder.length == 0) return null;
32+
if (preorder.length == 1) return new TreeNode(preorder[0]);
33+
int i = 0;
34+
List<Integer> leftPreorder = new ArrayList<>(); // O(N)
35+
List<Integer> leftInorder = new ArrayList<>(); // O(N)
36+
List<Integer> rightPreorder = new ArrayList<>(); // O(N)
37+
List<Integer> rightInorder = new ArrayList<>(); // O(N)
38+
for (; i < inorder.length; i++) { // O(N)
39+
if (inorder[i] == preorder[0]) break;
40+
leftPreorder.add(preorder[i+1]);
41+
leftInorder.add(inorder[i]);
42+
}
43+
for (int idx = i+1; idx < inorder.length; idx++) { // O(N)
44+
rightPreorder.add(preorder[idx]);
45+
rightInorder.add(inorder[idx]);
46+
}
47+
48+
return new TreeNode(preorder[0], buildTree(leftPreorder.stream().mapToInt(Integer::intValue).toArray(), leftInorder.stream().mapToInt(Integer::intValue).toArray()), buildTree(rightPreorder.stream().mapToInt(Integer::intValue).toArray(), rightInorder.stream().mapToInt(Integer::intValue).toArray()));
49+
}
50+
}
51+

0 commit comments

Comments
 (0)