Using a map instead of an array for Consecutive Subsequence?
What is state compression? It's when you represent states more efficiently to save memory. Instead of storing everything, you only store what you need.
Common techniques you'll see:
- Bitmask: Use bits to represent which elements you've selected.
- Coordinate Compression: When coordinates are huge, map them to smaller indices.
- Value Compression: When values are large (like ), use maps instead of arrays. As in Consecutive Subsequence!
The key idea: don't store states you'll never use. Only keep what matters.