본문 바로가기

리트코드47

❗️[LEET CODE] 641. Design Circular Deque # Problem Design your implementation of the circular double-ended queue (deque). Your implementation should support following operations: MyCircularDeque(k): Constructor, set the size of the deque to be k. insertFront(): Adds an item at the front of Deque. Return true if the operation is successful. insertLast(): Adds an item at the rear of Deque. Return true if the operation is successful. dele.. 2021. 3. 31.
[코딩 + 알고리즘 완주반] 17일차. 재귀용법, 동적계획법과 분할정복 # 재귀 용법 함수 안에서 동일한 함수를 호출 # 일반적인 형태 # 일반적인 형태1 def function(입력): if 입력 > 일정값: # 입력이 일정 값 이상이면 return function(입력 - 1) # 입력보다 작은 값 else: return 일정값, 입력값, 또는 특정값 # 재귀 호출 종료 # 일반적인 형태2 def function(입력): if 입력 2021. 3. 31.
[LEET CODE] 739. Daily Temperatures # Problem Given a list of daily temperatures T, return a list such that, for each day in the input, tells you how many days you would have to wait until a warmer temperature. If there is no future day for which this is possible, put 0 instead. For example, given the list of temperatures T = [73, 74, 75, 71, 69, 72, 76, 73], your output should be [1, 1, 4, 2, 1, 1, 0, 0]. Note: The length of temp.. 2021. 3. 29.
[LEET CODE] 622. Design Circular Queue # Problem Design your implementation of the circular queue. The circular queue is a linear data structure in which the operations are performed based on FIFO (First In First Out) principle and the last position is connected back to the first position to make a circle. It is also called "Ring Buffer". One of the benefits of the circular queue is that we can make use of the spaces in front of the .. 2021. 3. 29.
[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.
반응형