1353. Maximum Number of Events That Can Be Attended

```python class Solution: def maxEvents(self, events: List[List[int]]) -> int: “”” 1. sort by start 2. put the end time of events starting before current date into PQ 3. pop events that end earlier than current date off the PQ 4. cnt + 1, date +1, pop one event out “””... [Read More]
Tags: Array Greedy Heap

315. Count of Smaller Numbers After Self

class Solution: def countSmaller(self, A: List[int]) -> List[int]: n = len(A) res = [0] * n B = [] for i, v in enumerate(A): B.append((v,i)) def merge(l_arr, r_arr): """tc O(NlgN) sc O(N) 1. when both left array and right array is not running out, compare left[l] with right[r], move it... [Read More]
Tags: Array Greedy Heap

472. Concatenated Words

Top Down class Solution: def findAllConcatenatedWordsInADict(self, words: List[str]) -> List[str]: """tc O(N*W^2*2^W) sc O(N*W^2*2^W)?? O(N*W^2) W: avg len of word main idea: dfs + memo 1. create a global memo, put all words into set for O(1) look up 2. loop through all the words and check if it can... [Read More]
Tags: String DP DFS Trie

696. Count Binary Substrings

One Round Solution class Solution: def countBinarySubstrings(self, s: str) -> int: """ tc O(N) sc O(1) main idea: two pointer - cnt number 0 or 1 grouped consecutively, compare current value's occurance and previous opposite value's occurance => valid number of substring is min number of consecutive 0s and 1s... [Read More]