스택

Daily Temperatures - LeetCode Can you solve this real interview question? Daily Temperatures - Given an array of integers temperatures represents the daily temperatures, return an array answer such that answer[i] is the number of days you have to wait after the ith day to get a warmer leetcode.com 문제 기준의 날의 온도가 입력되어있는 리스트에서 기준 날의 온도보다 더 높은 온도를 기록한 날과의 날짜 차이를 입력한 리스트를 출력한다. 과정 output 리스트에 들어가는 값은..
9012번: 괄호 괄호 문자열(Parenthesis String, PS)은 두 개의 괄호 기호인 ‘(’ 와 ‘)’ 만으로 구성되어 있는 문자열이다. 그 중에서 괄호의 모양이 바르게 구성된 문자열을 올바른 괄호 문자열(Valid PS, VPS)이라고 www.acmicpc.net 더보기 문제 괄호 문자열(Parenthesis String, PS)은 두 개의 괄호 기호인 ‘(’ 와 ‘)’ 만으로 구성되어 있는 문자열이다. 그 중에서 괄호의 모양이 바르게 구성된 문자열을 올바른 괄호 문자열(Valid PS, VPS)이라고 부른다. 한 쌍의 괄호 기호로 된 “( )” 문자열은 기본 VPS 이라고 부른다. 만일 x 가 VPS 라면 이것을 하나의 괄호에 넣은 새로운 문자열 “(x)”도 VPS 가 된다. 그리고 두 V..
Implement Queue using Stacks - LeetCode Can you solve this real interview question? Implement Queue using Stacks - Implement a first in first out (FIFO) queue using only two stacks. The implemented queue should support all the functions of a normal queue (push, peek, pop, and empty). Implement t leetcode.com 문제 두 개의 스택만 사용하여 큐를 구현하라. push(): 요소를 대기열 뒤쪽으로 푸시합니다. pop(): 대기열의 앞부분에서 요소를 제거하고 반환합니다. ..
Implement Stack using Queues - LeetCode Can you solve this real interview question? Implement Stack using Queues - Implement a last-in-first-out (LIFO) stack using only two queues. The implemented stack should support all the functions of a normal stack (push, top, pop, and empty). Implement the leetcode.com 문제 큐를 이용해 다음 연산을 지원하는 스택을 구현하라. push(x): 요소 x를 스택에 삽입한다. pop(): 스택의 첫 번째 요소를 삭제한다. top()..
스택 한쪽 끝에서만 데이터를 넣고 뺄 수 있는 선형 자료구조이다. 후입선출(Last In First Out) 넣은 순서를 쌓아두고 있기 때문에 그 순서가 필요한 경우에 사용 ex) 컴퓨터의 되돌리기(Ctrl + Z) 기능 def test_node(): assert Node(1, None).item == 1 def test_stack(): stack = Stack() stack.push(1) stack.push(2) stack.push(3) stack.push(4) stack.push(5) assert stack.pop() == 5 assert stack.pop() == 4 assert stack.pop() == 3 assert stack.pop() == 2 assert stack.pop() == 1 as..
hihyuk
'스택' 태그의 글 목록