Skip to content

Commit 0bc4431

Browse files
authored
Merge branch 'DaleStudy:main' into main
2 parents 26ef844 + 2007a35 commit 0bc4431

File tree

164 files changed

+4399
-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.

164 files changed

+4399
-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/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/dalpang81.javaโ€Ž

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/*
2+
* ์‹œ๊ฐ„๋ณต์žก๋„ : O(N^2)
3+
* ๊ณต๊ฐ„๋ณต์žก๋„ : O(1)
4+
* */
5+
import java.util.*;
6+
7+
class Solution {
8+
public List<List<Integer>> threeSum(int[] nums) {
9+
List<List<Integer>> result = new ArrayList<>();
10+
Arrays.sort(nums);
11+
12+
for (int i = 0; i < nums.length - 2; i++) {
13+
if (i > 0 && nums[i] == nums[i - 1]) {
14+
continue;
15+
}
16+
17+
int left = i + 1;
18+
int right = nums.length - 1;
19+
20+
while (left < right) {
21+
int sum = nums[i] + nums[left] + nums[right];
22+
23+
if (sum == 0)
24+
{
25+
// ํ•ฉ์ด 0์ธ ๊ฒฝ์šฐ ๊ฒฐ๊ณผ์— ์ถ”๊ฐ€
26+
result.add(Arrays.asList(nums[i], nums[left], nums[right]));
27+
28+
// ์ค‘๋ณต๋œ ๊ฐ’ ๊ฑด๋„ˆ๋›ฐ๊ธฐ
29+
while (left < right && nums[left] == nums[left + 1])
30+
left++;
31+
32+
while (left < right && nums[right] == nums[right - 1])
33+
right--;
34+
35+
left++;
36+
right--;
37+
}
38+
else if (sum < 0)
39+
left++;
40+
else
41+
right--;
42+
43+
}
44+
}
45+
return result;
46+
}
47+
}

โ€Ž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+
}

โ€Ž3sum/heypaprika.pyโ€Ž

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# 2Sum์„ ํ™œ์šฉํ•œ ํ’€์ด
2+
# Note : ์ •๋ ฌ ํ›„ ํ‘ธ๋Š” ๊ฒƒ์ด ๋” ์ง๊ด€์ ์ด๊ณ , ๋น ๋ฆ„
3+
4+
"""
5+
๋ณต์žก๋„ : ์˜ˆ์ƒ -> ์˜ˆ์ƒํ•œ ์ด์œ 
6+
7+
์‹œ๊ฐ„ ๋ณต์žก๋„ : O(n^2) -> nums ๋ฐฐ์—ด 2์ค‘ for๋ฌธ
8+
๊ณต๊ฐ„ ๋ณต์žก๋„ : O(n) -> ์ตœ์•…์˜ ๊ฒฝ์šฐ nums ๋ฐฐ์—ด ๊ธธ์ด๋งŒํผ์˜ ๋”•์…”๋„ˆ๋ฆฌ ์ƒ์„ฑ
9+
"""
10+
class Solution:
11+
def threeSum(self, nums: List[int]) -> List[List[int]]:
12+
ans_list = set()
13+
added_pair = {}
14+
for target_i, target_number in enumerate(nums):
15+
cur_ans_list = []
16+
num_dict = {}
17+
if target_number in added_pair:
18+
continue
19+
20+
for i in range(target_i + 1, len(nums)):
21+
num_A = nums[i]
22+
num_B = - target_number - num_A
23+
if num_B in num_dict:
24+
cur_ans_list.append(sorted([target_number, num_A, num_B]))
25+
added_pair[target_number] = num_A
26+
num_dict[num_A] = 1
27+
for item in cur_ans_list:
28+
ans_list.add(tuple(item))
29+
return list(ans_list)
30+
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+
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/*
2+
์‹œ๊ฐ„๋ณต์žก๋„ : O(n)
3+
๊ณต๊ฐ„๋ณต์žก๋„ : O(n)
4+
*/
5+
class Solution {
6+
public int climbStairs(int n) {
7+
if (n <= 2) return n;
8+
9+
int[] dp = new int[n + 1];
10+
dp[1] = 1;
11+
dp[2] = 2;
12+
13+
for(int i = 3; i <= n; i++)
14+
dp[i] = dp[i - 1] + dp[i - 2];
15+
16+
return dp[n];
17+
18+
}
19+
}
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+
}

0 commit comments

Comments
ย (0)