일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | |||
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |
- 109. Convert Sorted List to Binary Search Tree
- Class
- DWG
- Python Implementation
- Python
- kaggle
- Decorator
- LeetCode
- 30. Substring with Concatenation of All Words
- Regular Expression
- attribute
- 시바견
- 운영체제
- Generator
- data science
- 715. Range Module
- Python Code
- 컴퓨터의 구조
- concurrency
- 파이썬
- shiba
- Convert Sorted List to Binary Search Tree
- iterator
- t1
- 43. Multiply Strings
- 프로그래머스
- 315. Count of Smaller Numbers After Self
- Protocol
- 밴픽
- Substring with Concatenation of All Words
- Today
- Total
목록Computer Science/Coding Test (225)
Scribbling
https://school.programmers.co.kr/learn/courses/30/lessons/150369 프로그래머스코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.programmers.co.kr The key is to eliminate the farthest houses.To identify the farthest ones, we may use max heaps. 1. Pythonimport heapqdef solution(cap, n, deliveries, pickups): h1 = [] h2 = [] for i, d in enumerate(deliveries): ..
https://leetcode.com/problems/the-earliest-moment-when-everyone-become-friends/description/ LeetCode - The World's Leading Online Programming Learning Platform 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 Solution: def earliestAcq(self, logs: List[List[int]], n: int) -> int: parent..
Q: Given arbitrary ranges, merge all the ranges that overlap with each other. Return the resultant ranges. 1. Sort all the ranges by their start and end. 2. Now that we know that range's start increases we have to take care of the ends --> We have to take care of the two cases below. 3. Code ranges = [] ranges.append(schedules[0]) for s, e in schedules: if s '[Interval]': schedules = [] for i in..
Q: Find the number of unique strings of which the length is L, given that the maximum number of consecutive vowels allowed is K. * There are 21 types of consonants and 5 types of vowels. For example, L=4, K=1: then allowed patterns are - CCCC CCCV, CCVC, CVCC, VCCC, VCVC, VCCV, CVCV This question can be easily handled with DFS. However, the approach would not be optimal as it involves unnecessar..
For a given recipe, we need to check whether all the necessary elements can be supplied. If an element belongs to supplies, it's a piece of cake. Now the question is to deal with elements that belong to recipes. We can think of recipes as a graph with cycles. Plus, if there's a cycle among certain recipes, they can never be cooked. class Solution: def findAllRecipes(self, recipes: List[str], ing..
First thing I came out with was to use a trie data structure, as it helps us deal with characters efficiently. class StreamChecker: def __init__(self, words: List[str]): self.trie = {} for word in words: node = self.trie for char in word: if char not in node: node[char] = {} node = node[char] node['#'] = '#' self.candidates = [] def query(self, letter: str) -> bool: self.candidates.append(self.t..
1. Using heaps with lazy removal Below code uses 'MyHeap' data structure, a heap with lazy removal. Lazy removal here means, if we have to remove an element, we handle it by using another heap as a trash can. import heapq class MyHeap: def __init__(self, type='min'): self.heap = [] self.removals = [] self.sign = 1 if type == 'min' else -1 def insert(self, elem): heapq.heappush(self.heap, self.si..
We need to deal with ranges to solve this problem. Below is the link of a wonderful solution. https://leetcode.com/problems/range-module/discuss/244194/Python-solution-using-bisect_left-bisect_right-with-explanation Python solution using bisect_left, bisect_right with explanation - LeetCode Discuss Level up your coding skills and quickly land a job. This is the best place to expand your knowledg..
The very first thing to do is looking for matches. We don't need to use any fancy algorithms when looking for matches in this problem because it is guranteed that replacements will not overlap. Now we have matched list in the form of [index, source, target]. If you are planning to replace s directly, it will lead to bad time complexity as you will have to copy all the characters of s each time y..
class Solution: def calculate(self, s: str) -> int: # ' ' is intentionally added, # to mark the end of the given string s # encountering ' ' will add the last number to the stack self.s = s + ' ' self.ptr = 0 return self.calc() def calc(self): num, stack, sign = 0, [], '+' while self.ptr < len(self.s): c = self.s[self.ptr] # if met with '(', # get the evaluated number by recursion if c == '(': s..