Skip to content

Latest commit

 

History

History
35 lines (31 loc) · 1.47 KB

File metadata and controls

35 lines (31 loc) · 1.47 KB

Competitive coading with python

1. Check the recurision limit in python

import sys
print(sys.getrecursionlimit())

2. Subarray , substring, subsequence, subset
-> Subarray - Contigious block of memory
-> Substring - Contigious block of string
-> Subsequence - Sequence derieved from other sequence by ading or deleting elements but without changing the order
-> Subset - Any possible combination of the original set. It does not maintan the relative order of the string

3. Matrix ( mat: List[List[int]] ) resizing
-> 2-d array to 1-d: M[i][j]=M[c*i+j] , where n is the number of cols. This is the one way of converting 2-d indices into one 1-d index.
-> 1-d array to 2-d: M[i] => M[i/n][i%n] convert 1d to 2d.

mat = [[0 for _ in range(cols)]]*rows to initialize 2d matrix
mat [0] * r * c to initilize 1d array

4.Which approach?
-> Top/ Maximum / Closest element --> HEAP
-> Sorted array / List --> Binary Search / Two pointer method
-> Combination / Permutation --> Backtracking / BFS
-> Tree / Graph --> BFS/ DFS
-> Recursive solution / iterative --> Stack
-> Array solution --> O(n2)/ O(1) --> Hashing / sets O(n):O(n) // sorting (nlogn)
-> Optimization --> Dynamic programming (Op= Maximization/minimizaton)
-> Common / substring / string --> Hashmap/tree
-> Search/ Manupulate strings --> tree
-> Linked list with no extra space --> Fast and slow pointer