Skip to content

Commit 6552d8f

Browse files
Merge pull request #2169 from CodingTestStudy2/최원준
[최원준] 2026/10/13
2 parents 6b4976e + a135ead commit 6552d8f

3 files changed

Lines changed: 61 additions & 0 deletions

File tree

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#
2+
3+
'''
4+
1. 아이디어 :
5+
미리 trip마다 탑승, 내리는 인원들을 구합니다.
6+
7+
2. 시간복잡도 :
8+
O(n+n)
9+
10+
3. 자료구조/알고리즘 :
11+
-
12+
13+
'''
14+
class Solution:
15+
def carPooling(self, trips: list[list[int]], capacity: int) -> bool:
16+
n = len(trips)
17+
boarding = [0] * 1001
18+
curr = 0
19+
20+
for passengers, start, end in trips:
21+
boarding[start] += passengers
22+
boarding[end] -= passengers
23+
24+
for i in range(1000):
25+
curr += boarding[i]
26+
if curr > capacity:
27+
return False
28+
29+
return True
30+
31+
32+
33+

leetcode3/4056. Number of Intersecting Interval Pairs I.py renamed to leetcode3/최원준/4056. Number of Intersecting Interval Pairs I.py

File renamed without changes.
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#
2+
3+
'''
4+
1. 아이디어 :
5+
최대 2번 움직입니다
6+
0번: 같은 점
7+
1번: 같은 가로/세로/대각
8+
2번: 위 제외 나머지
9+
10+
2. 시간복잡도 :
11+
O(1)
12+
13+
3. 자료구조/알고리즘 :
14+
-
15+
16+
'''
17+
class Solution:
18+
def minQueenMoves(self, source: list[int], target: list[int]) -> int:
19+
s1, s2 = source
20+
e1, e2 = target
21+
22+
if s1 == e1 and s2 ==e2:
23+
return 0
24+
if s1 == e1 or s2 == e2 or abs(s1-e1) == abs(s2-e2):
25+
return 1
26+
return 2
27+
28+

0 commit comments

Comments
 (0)