Algorithm (130) 썸네일형 리스트형 [스택, 큐] 23 큐를 이용한 스택 구현(Implement Stack using Queues) - 작성중 https://leetcode.com/problems/implement-stack-using-queues/ Implement Stack using Queues - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com 큐를 이용해 스택의 push, pop, top, empty 연산을 구현하는 문제입니다. deque에서 append와 popleft만 이용해서 FIFO인 queue로 이용합니다. 1. 큐를 하나만 이용(삽입시 O(N)) queue에서 append할때 새로 a.. [스택, 큐] 22 일일 온도(Daily Temperatures) - 작성중 https://leetcode.com/problems/daily-temperatures/ Daily Temperatures - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com 매일의 화씨 온도 리스트 T를 입력받아서, 더 따뜻한 날씨를 위해서는 며칠을 더 기다려야 하는지를 출력하는 문제입니다. class Solution: def dailyTemperatures(self, temperatures: List[int]) -> List[int]: ans=[0]*len(t.. [스택, 큐] 21 중복 문자 제거(Remove Duplicate Letters) - 작성중 https://leetcode.com/problems/remove-duplicate-letters/ Remove Duplicate Letters - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com 중복된 문자를 제외하고 사전식 순서로 나열하는 문제입니다. 문제를 정확히 이해해야 풀 수 있는 문제입니다. 1. 1. [스택, 큐] 20 유효한 괄호(Valid Parentheses) https://leetcode.com/problems/valid-parentheses/ Valid Parentheses - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com 괄호로 된 입력값이 올바른지 판별하는 문제입니다. 전형적인 스택 문제입니다. (,{,[에서는 스택에 push하고 ),},]에서는 스택에서 pop한 결과가 mapping되는지 확인합니다. 이를 위해서 매핑 테이블을 미리 만들어줘야 합니다. 그리고 pop할때 스택이 비어있으면 안되므로 비어있는 상황.. [연결리스트] 19 역순 연결 리스트 II(Reverse Linked List II) https://leetcode.com/problems/reverse-linked-list-ii/ Reverse Linked List II - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com 인덱스 m에서 n까지를 역순으로 만드는 문제입니다. 이때, 인덱스는 0이 아닌 1부터 시작합니다. # Definition for singly-linked list. # class ListNode: # def __init__(self, val=0, next=None): # sel.. [연결리스트] 18 홀짝 연결 리스트(Odd Even Linked List) https://leetcode.com/problems/odd-even-linked-list/ Odd Even Linked List - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com # Definition for singly-linked list. # class ListNode: # def __init__(self, val=0, next=None): # self.val = val # self.next = next class Solution: def oddEvenL.. [연결리스트] 17 페어의 노드 스왑(Swap Nodes in Pairs) https://leetcode.com/problems/swap-nodes-in-pairs/ Swap Nodes in Pairs - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com 연결리스트를 2칸씩이동하며 값을 swap해주면 됩니다. # Definition for singly-linked list. # class ListNode: # def __init__(self, val=0, next=None): # self.val = val # self.next = next.. [연결리스트] 16 두 수의 덧셈(Reverse Linked List) https://leetcode.com/problems/add-two-numbers/ Add Two Numbers - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com 역순으로 저장된 연결 리스트의 숫자를 더하는 문제입니다. 연결리스트의 값들을 문자열로 이어붙이고 숫자로 변환한 다음 계산한 결과를 다시 연결리스트로 바꾸면 됩니다. # Definition for singly-linked list. # class ListNode: # def __init__(self, v.. 이전 1 2 3 4 5 ··· 17 다음