- [[Two Pointers]]
- [[Sliding Window]]
- [[Prefix Sum]]
- [[String Building]]
### General
![[Array Chart.png]]
![[CleanShot 2024-05-15 at
[email protected]]]
- in Python you have "lists", where elements of different types can be added to the same list
- whereas in languages like C++, you have to specify the size & data type of the array in initialization
### Subarray/Substring vs Subsequence vs Subset
- subarray/substring is a contiguous section of an array or string
- but subsequence is a set of elements in the array/string that *doesn't need to be contiguous*, but has to **keep the same relative order**
- subsequence problems are usually harder
- subset is any set of elements from the original array/string
- order doesn't matter and doesn't have to be contiguous
- subsets containing the same elements in different order are considered the same
- sometimes problems ask about subsequences, but the order of subsequence doesn't actually matter (i.e sum of subsequences)
- you can treat them as subsets instead
- subsets allow you to sort the original input array, unlike subsequences, since the order doesn't matter