Skip to content

Commit

Permalink
Merge pull request #58 from AlgoLeadMe/14-2secondag
Browse files Browse the repository at this point in the history
12-2secondag
  • Loading branch information
2secondag authored Feb 19, 2024
2 parents 8d1f040 + 453cf66 commit 04a2e25
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 2 deletions.
2 changes: 0 additions & 2 deletions 2secondag/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,3 @@
| 9μ°¨μ‹œ | 2024.01.25 | μˆ˜ν•™ | [λ‹¬νŒ½μ΄λŠ” μ˜¬λΌκ°€κ³  μ‹Άλ‹€] (https://www.acmicpc.net/problem/2869) | [#37](https://github.com/AlgoLeadMe/AlgoLeadMe-5/pull/37#event-11619409875)|
| 10μ°¨μ‹œ | 2024.01.28 | κ΅¬ν˜„ | [μŒκ³„] (https://www.acmicpc.net/problem/2920) | [#39](https://github.com/AlgoLeadMe/AlgoLeadMe-5/pull/39#event-11655882785)|
| 11μ°¨μ‹œ | 2024.01.31 | λΆ€λ£¨νŠΈν¬μŠ€ μ•Œκ³ λ¦¬μ¦˜ | [λΈ”λž™μž­] (https://www.acmicpc.net/problem/2798) | [#46]()|

---
33 changes: 33 additions & 0 deletions 2secondag/μŠ€νƒ/μŠ€νƒ.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import sys

N = int(sys.stdin.readline())
stack = []

for i in range (N):
sen = list(map(str, sys.stdin.readline().split()))

if sen[0] == "push":
stack.append(int(sen[1]))

elif sen[0] == "pop":
if len(stack) > 0:
print(stack[-1])
stack.pop()
else:
print(-1)

elif sen[0] == "size":
print(len(stack))

elif sen[0] == "empty":
if len(stack) > 0:
print(0)
else:
print(1)

elif sen[0] == "top":
if len(stack)>0 :
print(stack[-1])
else:
print(-1)

0 comments on commit 04a2e25

Please sign in to comment.