File tree Expand file tree Collapse file tree 5 files changed +109
-0
lines changed
binary-tree-maximum-path-sum Expand file tree Collapse file tree 5 files changed +109
-0
lines changed Original file line number Diff line number Diff line change 1+ """
2+ [문제풀이]
3+ # Inputs
4+
5+ # Outputs
6+
7+ # Constraints
8+
9+ # Ideas
10+
11+ [회고]
12+
13+ """
14+
15+
Original file line number Diff line number Diff line change 1+ """
2+ [문제풀이]
3+ # Inputs
4+
5+ # Outputs
6+
7+ # Constraints
8+
9+ # Ideas
10+
11+ [회고]
12+
13+ """
14+
15+
Original file line number Diff line number Diff line change 1+ """
2+ [문제풀이]
3+ # Inputs
4+
5+ # Outputs
6+
7+ # Constraints
8+
9+ # Ideas
10+
11+ [회고]
12+
13+ """
14+
15+
Original file line number Diff line number Diff line change 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+
Original file line number Diff line number Diff line change 1+ """
2+ [문제풀이]
3+ # Inputs
4+
5+ # Outputs
6+
7+ # Constraints
8+
9+ # Ideas
10+
11+ [회고]
12+
13+ """
14+
15+
You can’t perform that action at this time.
0 commit comments