-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
22 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
def solution(s): | ||
answer = 0 | ||
|
||
stack = [float("inf")] | ||
|
||
# 문자열을 공백 기준으로 나누어 리스트에 저장 | ||
s_list = s.split() | ||
|
||
for i in s_list: # i는 s_list의 인덱스가 아닌 값 | ||
if i != 'Z': | ||
stack.append(i) | ||
else: | ||
stack.pop() # stack의 가장 위의 값 빼기 | ||
stack.pop(0) | ||
|
||
# 문자를 정수로 변환하기 | ||
for i in stack: | ||
n = int(i) | ||
answer += n | ||
return answer |