1371. Find the Longest Substring Containing Vowels in Even Counts

```python class Solution: def findTheLongestSubstring(self, s: str) -> int: “"”tc O(N) sc O(2^M) use a counter to get # each vowels if in substring, if vowel = 0, can keep increasing XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX main idea: bit mask. note it's not about counting number of each vowels in string. it's check if... [Read More]
Tags: String

930. Binary Subarrays With Sum

class Solution: def numSubarraysWithSum(self, A: List[int], goal: int) -> int: """ tc O(N) sc O(1) (assuming each item in A is non-negtive ) 1. corner case if target < 0 2. left, right ptr start with head. start with K, keep substract current item the right ptr pointing at 3.... [Read More]

301. Remove Invalid Parentheses

```python class Solution: def removeInvalidParentheses(self, s: str) -> List[str]: “"”tc O(2^N) sc O(N) return all results => backtracking? (maintain current path valid) + with minimun removal =how to determine valid? ==> main idea: generate unique answer exactly once (no rely on set) to find out last removal position, we need... [Read More]
Tags: DFS BFS

1882. Process Tasks Using Servers

```python class Solution: def assignTasks(self, servers: List[int], tasks: List[int]) -> List[int]: “”” tc O(SlgS+T*lgT) sc O(S) main idea: two PQ “”” available = [[w,j] for j,w in enumerate(servers)] # (weight,idex) unava = [] # (available at time ,w, idx) heapq.heapify(available) cur_t = 0 n = len(tasks) res = []#[-1] *n... [Read More]
Tags: Heap