본문 바로가기

분류 전체보기

(248)
[스택, 큐] 25 원형 큐 디자인(Design Circular Queue) - 작성중 https://leetcode.com/problems/design-circular-queue/ Design Circular Queue - 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 class MyCircularQueue: def __init__(self, k: int): self.q = [None]*k #배열로 원형큐 정의 self.maxlen = k #최대길이 저장 self.p1 = 0 #front 포인터 self.p2 = 0 #rear 포인터 #rear ..
[스택, 큐] 24 스택을 이용한 큐 구현(Implement Queue using Stacks) - 작성중 https://leetcode.com/problems/implement-queue-using-stacks/ Implement Queue using Stacks - 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 input과 output 두 개의 스택을 이용해서 queue를 구현합니다. output 스택에 아무것도 없는 상태에서 pop을 수행하려고 할 때 input 스택에 쌓여있는 값들을 전부 output 스택으로 이관시키는 것이 포인트입니다! class MyQue..
[스택, 큐] 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.
HackaLearn 참여 후기 참여팀명: 월급두배받는법 내 이름: 천호영 내 github ID: https://github.com/HoYoungChun HoYoungChun - Overview HoYoungChun has 19 repositories available. Follow their code on GitHub. github.com 내 microsoft 프로필: https://docs.microsoft.com/ko-kr/users/92982145/ 프로필 docs.microsoft.com svelte는 짧은 기간내에 개발하기 편한 프레임워크라 생각합니다. 최근에 백엔드 개발만 했었는데 html, css 오랜만에 보니 재밌고, HackaLearn을 통해 성장하고 있음을 느낍니다. HackaLearn 짱! https://githu..
range와 slicing 문법의 차이 range와 slicing의 문법의 차이를 정리하려 합니다. 1. range range 함수는 range객체(immutable sequence of numbers)를 반환합니다. https://docs.python.org/3/library/stdtypes.html#range 1) range(stop) - start는 0으로, step은 1로 고정 2) range(start, stop[, step]) - step은 안주어지면 1로 설정됨 >>> list(range(10)) [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] >>> list(range(1, 11)) [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] >>> list(range(0, 30, 5)) [0, 5, 10, 15, 20, 2..
[스택, 큐] 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할때 스택이 비어있으면 안되므로 비어있는 상황..