Leetcode(21)
-
Leetcode 46. Permutations
Leetcode 46. Permutations Permutations - LeetCode Permutations - 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 Logic DFS로 깊이탐색 prev는 추가되고 next는 줄어들면서 dfs를 돈다 Solution from typing import List class Solution: def permute(self, nums: List[int]) -> List[List[int]]: prev = [] answer =..
2021.01.29 -
[Leetcode] 347. Top K Frequent Elements
Leetcode 347. Top K Frequent Elements https://leetcode.com/problems/top-k-frequent-elements/ Top K Frequent Elements - 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 collections.Counter() 이용한 풀이. most_common()메소드를 사용했다. collections.Counter() import collections from typi..
2021.01.26 -
[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 -
[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