https://leetcode.com/problems/sliding-window-maximum First Solution Time Complexity: O((n – k) * log(k)) Space Complexity: O(k) (The input and output generally do not count towards the space com ...        
        
        
      
      
      
      
       
		  		  			                  
      
        
        
		        
                
                
        
		  timeit timeit timeit.timeit(   stmt='pass',   setup='pass',   timer=<default timer>,   number=1000000,   globals=None ) repeat timeit.repeat(   stmt='pass',   setup='pass',   timer=<default t ...        
        
        
      
      
      
      
       
		  		  			                  
      
        
        
		        
                
                
        
		  https://leetcode.com/problems/partition-list Solution ge_cur.next = cur ge_cur = cur → ge_cur = ge_cur.next = cur ⇒ 1. ge_cur ← cur 2. ge_cur.next ≡ cur.next ← cur ⇒ loop ge_cur.next = ge_cur = cur ⇒  ...        
        
        
      
      
      
      
       
		  		  			                  
      
        
        
		        
                
                
        
		  Naming grid is a m × n matrix m := len(grid) n := len(grid[0]) $$ grid = \left| \begin{aligned} & a_{0, 0} & \quad & a_{0, 1} & \quad & a_{0, 2} & \quad & … & \qu ...        
        
        
      
      
      
      
       
		  		  			                  
      
        
        
		        
                
                
        
		  Naming Convention Python Class and Function/Method (UpperCamelCase) Constant (CAPITALIZED_WITH_UNDERSCORES) Others (lowercase_separated_by_underscores) Underscore Before a Name (name_) Avoid Keyword C ...        
        
        
      
      
      
      
       
		  		  			                  
      
        
        
		        
                
                
        
		  https://leetcode.com/problems/the-maze Solution m := len(maze) n := len(maze[0]) Time Complexity: O(m * n) Space Complexity: O(m * n) (The input and output generally do not count towards the space com ...        
        
        
      
      
      
      
       
		  		  			                  
      
        
        
		        
                
                
        
		  https://leetcode.com/problems/kth-largest-element-in-an-array Solution n := len(nums) Time Complexity: O(n * log(k)) Space Complexity: O(k) (The input and output generally do not count towards the spa ...        
        
        
      
      
      
      
       
		  		  			                  
      
        
        
		        
                
                
        
		  https://leetcode.com/problems/check-if-there-is-a-valid-partition-for-the-array Solution n := len(nums) Time Complexity: O(3 ** n)O(n) (due to memoization) Space Complexity: O(n) (The input and output ...        
        
        
      
      
      
      
       
		  		  			                  
      
        
        
		        
                
                
        
		  math Module math.inf ∞, ≡ float(“inf”) math.prod(iterable, *, start=1) def prod(iterable, *, start=1):   for element in iterable:     start *= element   return start math.floor(f) -> in ...        
        
        
      
      
      
      
       
		  		  			                  
      
        
        
		        
                
                
        
		  https://leetcode.com/contest/weekly-contest-358/problems/apply-operations-to-maximize-score/ First Solution (Time Limit Exceeded) Time Complexity: O(n * (A + n)) A := max(nums) n := len(nums) compute  ...