Stack
Introduction
스택을 구현하고 사용해 봅시다.
Example
https://www.acmicpc.net/step/11
괄호
주어진 문자열이 올바른 괄호열인지 판단하는 문제
아래는 스택으로 풀지 않았다.
import sys
input = sys . stdin . readline
T = int ( input ())
for _ in range ( T ):
strings = input (). rstrip ()
cnt = 0
error = False
for s in strings :
if s == '(' :
cnt += 1
elif s == ')' :
cnt -= 1
if cnt < 0 :
error = True
break
if error == True :
print ( "NO" )
else :
if cnt != 0 :
print ( "NO" )
else :
print ( "YES" )
균형잡힌 세상
위와 같은데 괄호의 종류가 다양해진 문제
import sys
input = sys . stdin . readline
strings = input (). rstrip ()
while strings != '.' :
check_stack = []
error = False
for s in strings :
if s == '(' or s == '[' :
check_stack . append ( s )
elif s == ')' :
if len ( check_stack ) > 0 :
check = check_stack . pop ()
if check != '(' :
error = True
break
else :
error = True
break
elif s == ']' :
if len ( check_stack ) > 0 :
check = check_stack . pop ()
if check != '[' :
error = True
break
else :
error = True
break
if error == True :
print ( "no" )
else :
if len ( check_stack ) == 0 :
print ( "yes" )
else :
print ( "no" )
strings = input (). rstrip ()
오큰수
Please enable JavaScript to view the comments powered by Disqus.
2022
2 minute read
Introduction
less than 1 minute read
Introduction
1 minute read
Introduction
less than 1 minute read
Introduction
1 minute read
Introduction
less than 1 minute read
Introduction
1 minute read
Introduction
less than 1 minute read
Introduction
less than 1 minute read
Introduction
less than 1 minute read
Introduction
less than 1 minute read
Introduction
1 minute read
Introduction
1 minute read
Introduction
1 minute read
Introduction
less than 1 minute read
Introduction
less than 1 minute read
Introduction
less than 1 minute read
Introduction
less than 1 minute read
Introduction
less than 1 minute read
Introduction
less than 1 minute read
Introduction
less than 1 minute read
Introduction
less than 1 minute read
Introduction
less than 1 minute read
Introduction
less than 1 minute read
Introduction
1 minute read
Introduction
3 minute read
Introduction
1 minute read
Introduction
1 minute read
Introduction
1 minute read
Introduction
less than 1 minute read
Introduction
1 minute read
Introduction
less than 1 minute read
Introduction
1 minute read
Introduction
less than 1 minute read
Introduction
2 minute read
Introduction
less than 1 minute read
Introduction
2 minute read
Introduction
1 minute read
Introduction
less than 1 minute read
Introduction
1 minute read
Introduction
less than 1 minute read
Introduction
2 minute read
Introduction
1 minute read
Introduction
3 minute read
1167 트리의 지름
3 minute read
Introduction
1 minute read
Introduction
2 minute read
Introduction
less than 1 minute read
Introduction
4 minute read
Introduction
less than 1 minute read
Introduction
6 minute read
Introduction
2 minute read
Introduction
1 minute read
Introduction
less than 1 minute read
Introduction
3 minute read
Introduction
2 minute read
Introduction
2 minute read
Introduction
3 minute read
Introduction
less than 1 minute read
Git 명령어를 사용한 하위 디렉토리 다운로드
Clone 할 로컬 저장소 생성
1 minute read
Introduction
less than 1 minute read
# Fetch the submodule commits into the main repository
git remote add submodule_origin git://url/to/submodule/origin
git fetch submodule_origin
less than 1 minute read
Introduction
less than 1 minute read
Introduction
3 minute read
Introduction
less than 1 minute read
Introduction
less than 1 minute read
Introduction
3 minute read
Introduction
less than 1 minute read
Introduction
4 minute read
Introduction
less than 1 minute read
Introduction
less than 1 minute read
Introduction
2 minute read
Introduction
less than 1 minute read
Introduction
1 minute read
Introduction
less than 1 minute read
Spring Project
less than 1 minute read
the page for java
3 minute read
가벼운 Base image를 사용
less than 1 minute read
version: 3.0.0a10
less than 1 minute read
WIDTH
less than 1 minute read
version: 3.0.0a10
less than 1 minute read
#include <iostream>
#include <thread>
#include <chrono>
#include <mutex>
#include <atomic>
#include <string.h>
1 minute read
version: 3.0.0a10
less than 1 minute read
https://cplusplus.com/reference/future/
less than 1 minute read
Multithreading support was introduced in C++11.
less than 1 minute read
how to costom github blog using jekyll
less than 1 minute read
You’ll find this post in your _posts directory. Go ahead and edit it and re-build the site to see your changes. You can rebuild the site in many different wa...
Back to top ↑