Skip to content

Commit 210fabc

Browse files
authored
Merge pull request #1575 from shinsj4653/main
[shinsj4653] Week 11 Solutions
2 parents 9f4fc39 + d6027b5 commit 210fabc

File tree

5 files changed

+109
-0
lines changed

5 files changed

+109
-0
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
"""
2+
[문제풀이]
3+
# Inputs
4+
5+
# Outputs
6+
7+
# Constraints
8+
9+
# Ideas
10+
11+
[회고]
12+
13+
"""
14+
15+

graph-valid-tree/shinsj4653.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
"""
2+
[문제풀이]
3+
# Inputs
4+
5+
# Outputs
6+
7+
# Constraints
8+
9+
# Ideas
10+
11+
[회고]
12+
13+
"""
14+
15+

merge-intervals/shinsj4653.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
"""
2+
[문제풀이]
3+
# Inputs
4+
5+
# Outputs
6+
7+
# Constraints
8+
9+
# Ideas
10+
11+
[회고]
12+
13+
"""
14+
15+

missing-number/shinsj4653.py

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
"""
2+
[문제풀이]
3+
# Inputs
4+
nums -> n개의 중복되지 않는 숫자들 (0 ~ n)
5+
6+
# Outputs
7+
유일하게 0 ~ n 범위에 포함되어 있지 않은 수
8+
9+
# Constraints
10+
n == nums.length
11+
1 <= n <= 10^4
12+
0 <= nums[i] <= n
13+
All the numbers of nums are unique.
14+
15+
16+
# Ideas
17+
18+
O(1) SC, O(n) TC로 할 수 있을까?
19+
-> 처음엔 당연히 사전 쓰면 되겠지했지만, O(1) SC가 안됨
20+
21+
정렬도 nlogn..
22+
23+
길이 : n
24+
0부터 n 까지 합 =>
25+
n = 3
26+
27+
0 1 2 3 -> 6
28+
sum(nums) -> 4
29+
남은 수 : 2
30+
31+
[회고]
32+
이게 맞네
33+
1부터 n 까지 합 공식 -> (n * (n + 1)) // 2
34+
35+
"""
36+
37+
38+
class Solution:
39+
def missingNumber(self, nums: List[int]) -> int:
40+
n = len(nums)
41+
s = sum(nums)
42+
43+
total_s = 0
44+
45+
for i in range(n + 1):
46+
total_s += i
47+
48+
return total_s - s
49+

reorder-list/shinsj4653.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
"""
2+
[문제풀이]
3+
# Inputs
4+
5+
# Outputs
6+
7+
# Constraints
8+
9+
# Ideas
10+
11+
[회고]
12+
13+
"""
14+
15+

0 commit comments

Comments
 (0)