본문 바로가기

9

[LEET CODE] 232. Implement Queue using Stacks # Problem 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 the MyQueue class: void push(int x) Pushes element x to the back of the queue. int pop() Removes the element from the front of the queue and returns it. int peek() Returns the element at the front of the queu.. 2021. 3. 26.
[LEET CODE] 225. Implement Stack using Queues # Problem Implement a last in first out (LIFO) stack using only two queues. The implemented stack should support all the functions of a normal queue (push, top, pop, and empty). Implement the MyStack class: void push(int x) Pushes element x to the top of the stack. int pop() Removes the element on the top of the stack and returns it. int top() Returns the element on the top of the stack. boolean.. 2021. 3. 26.
[코딩 + 알고리즘 완주반] 11일차. 배열, 큐 # 꼭 알아둬야 할 자료구조 - 배열 데이터를 나열하고 각 데이터를 인덱스에 대응하도록 구성한 데이터 구조 파이썬에서는 리스트 타입이 배열 기능을 제공하고 있음 장점 - 빠른 접근 가능 단점 - 데이터 추가/삭제가 어렵다 # 파이썬과 배열 파이썬 리스트 활용 # 대표적인 데이터 구조 : 큐 FIFO ( First in First Out) ( 줄을 서는 것과 유사) LILO ( Last In Last Out) # 용어 enqueue : 데이터를 넣는 기능 dequeue : 데이터를 빼는 기능 # 파이썬 큐 라이브러리( import queue ) Queue() : 가장 일반적인 큐 자료 구조 - put, get, qsize LifoQueue() : 나중에 입력된 데이터가 먼저 출력되는 구조(스택구조) - p.. 2021. 3. 25.
반응형