Skip to content

Commit c6d6c49

Browse files
authored
Merge pull request #605 from Yujin-Baek/main
[백유진] 87차 라이브 코테 제출
2 parents 37fa749 + be8371d commit c6d6c49

File tree

3 files changed

+48
-0
lines changed

3 files changed

+48
-0
lines changed

live8/test87/문제1/백유진.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
def solution(numbers):
2+
n = len(numbers)
3+
answer = [-1] * n
4+
stack = []
5+
6+
for i in range(n):
7+
while stack and numbers[stack[-1]] < numbers[i]:
8+
index = stack.pop()
9+
answer[index] = numbers[i]
10+
11+
stack.append(i)
12+
13+
return answer

live8/test87/문제2/백유진.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
def solution(people, limit):
2+
answer = 0
3+
sorted_people = sorted(people)
4+
start = 0
5+
end = len(people)-1
6+
7+
while start <= end:
8+
if sorted_people[start] + sorted_people[end] <= limit:
9+
start += 1
10+
end -= 1
11+
answer += 1
12+
return answer

live8/test87/문제3/백유진.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
def solution(dirs):
2+
answer = 0
3+
x, y = 0, 0
4+
udrl = {'U': (1, 0), 'D': (-1, 0), 'R': (0, 1), 'L': (0, -1)}
5+
history = set()
6+
7+
for dir in dirs:
8+
dy = udrl[dir][0]
9+
dx = udrl[dir][1]
10+
11+
ny = y + dy
12+
nx = x + dx
13+
14+
if -5 <= ny <=5 and -5 <= nx <= 5:
15+
history.add(((ny, nx),(y, x)))
16+
history.add(((y, x),(ny, nx)))
17+
18+
y = ny
19+
x = nx
20+
21+
print(history)
22+
23+
return len(history)/2

0 commit comments

Comments
 (0)