### Time Complexity
--- $O(1)$
- $O(log n)$
- $O(n)$
- $O(n log n)$
- $O(n^2)$
- $O(n!)$
### Sliding Window
--A common algorithm, with two variations variable length and fixed length. For any sliding window
problem we are generally given an array or string. If the question mentions **sub-arrays** or
**sub-strings**, then the sliding window technique may be an efficient solution. A sub-array/substring are contiguous non-empty sequence derived from the original array/string. In the sliding
window technique we always need to ask if our window is **valid**, this validity is different
depending on the condition presented in the problem. We increase the right boundary if the window
is valid and we increase the left boundary if the window is invalid.
### Hashing, Sets, Maps
--A useful tool in python is the ```
```python
from collections import defaultdict
_map = defaultdict(T) # Where T is any valid python type
```
The main difference from the standard `dictionary` is the fact it provides default values for keys that
do not exist and never raises a `KeyError`.
Collisions in these data structures are possible and can be resolved by chaining or probing.
Chaining is simply having a (linked) list or array so that each hash key can hold multiple values.
Probing is simply searching for the next available slot when collision occurs.
Operations on these structures or often $O(1)$ amortised
### Two Pointer
--This technique employs a left and right pointer where the left is typically at the start of the sequence
and right is typically at the end of the sequence. Each iteration we either increment left or
decrement right depending on the scenario.
### Stacks and Queues
--A stack can be implemented simply as an array where push is `append()`, pop is simply`pop()`, peek
is `stack[-1]`. The stack is empty is `if stack:` condition fails. A stack follows the Last In Last Out
policy. Conversely a stack follows the First in First out policy, we can use:
```python
from collections import deque
queue = deque()
queue.appendleft()
queue.pop(left)
```