Problem Solving(68)
-
BOJ 1806. 부분합 (Python)
BOJ-1806. 부분합 https://www.acmicpc.net/problem/1806 1806번: 부분합 첫째 줄에 N (10 ≤ N < 100,000)과 S (0 < S ≤ 100,000,000)가 주어진다. 둘째 줄에는 수열이 주어진다. 수열의 각 원소는 공백으로 구분되어져 있으며, 10,000이하의 자연수이다. www.acmicpc.net Solution import sys N, S = map(int, input().split()) list = list(map(int, input().split())) sum_untill_n = [0] * (N+1) for i in range(1, N + 1): sum_untill_n[i] = sum_untill_n[i-1] + list[i-1] min_leng..
2021.01.25 -
[Leetcode] 771. Jewels and Stones
Leetcode 771. Jewels and Stones (3) Jewels and Stones - LeetCode Jewels and Stones - 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 Solution 1 리스트와 파이썬의 if x in y문법을 이용한 풀이. class Solution: def numJewelsInStones(self, jewels: str, stones: str) -> int: count = 0 J = ' '.join(jewels..
2021.01.19 -
[Leetcode] 706. Design HashMap
Leetcode 706.Design HashMap https://leetcode.com/problems/design-hashmap/ Design HashMap - 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 Solution 파이썬의 대표적인 해시형 자료형인 딕셔너리이용 class MyHashMap: def __init__(self): self.dict = {} def put(self, key: int, value: int) -> None: self.dict[k..
2021.01.19 -
[자료구조] Circle Deque (원형 덱) 구현
Circle Deque (원형 덱) class MyCircularDeque: def __init__(self, k: int): self.q = [None] * (k+1) self.max = k+1 self.front = 0 self.rear = 0 def insert_front(self, value: int): if self.is_full(): print('Deque is Full') else: self.q[self.front] = value self.front = (self.front - 1 + self.max) % self.max def insert_last(self, value: int): if self.is_full(): print('Deque is Full') else: self.rear = (..
2021.01.19 -
[Leetcode] 641. Design Circular Deque
Leetcode 641. Design Circular Deque https://leetcode.com/problems/design-circular-deque/ Design Circular Deque - 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 Solution class MyCircularDeque: def __init__(self, k: int): self.q = [None] * (k+1) self.max = k+1 self.front = 0 self.re..
2021.01.19 -
[Leetcode] 622. Design Circular Queue
Leetcode 622. Design Circular Queue (3) Design Circular Queue - LeetCode 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 Solution class MyCircularQueue: def __init__(self, k: int): self.q = [None] * (k+1) self.max = k + 1 self.front = 0 self.rear = 0 def enQ..
2021.01.18