LC1707. Maximum XOR With an Element From Array

class Trie: def __init__(self,): self.root = {} def insert(self,x): p = self.root for i in range(32)[::-1]: cur = (x>>i) & 1 if cur not in p: p[cur] = {} p = p[cur] def query_max_XOR(self,x): res,p = 0, self.root if not p: return -1 for i in range(32)[::-1]: cur = (x>>i)&1... [Read More]

LC90. Subsets II

```python class Solution: def subsetsWithDup(self, A: List[int]) -> List[List[int]]: “"”tc O(N2^N) sc O(N2^N) 1. sort the array 2. in recursion function, when it comes to same value, skip “”” res = [] A.sort() def btr(start,path): res.append(path[:]) for i in range(start,len(A)): # note here use i>start instead of i > 0,... [Read More]