Bitmask DP: DP Over Subsets
Data Structures & Algorithms · Advanced Dynamic Programming · Master · 30 min
Store a set of up to about 20 items in one integer, run DP over all 2^n sets (assignment, travelling salesman), and loop over the submasks of a mask.
This lesson is part of TuringPath Pro. See plans.
What you will learn
- A set of up to 20 things fits in one number
- Remember which, forget the order
- Travelling salesman: also remember where you stand
- Looping over the submasks of a mask
More in Advanced Dynamic Programming
- Interval DP: Ranges, Splits and the Last Move
- Tree DP: Answers That Flow Up
- Digit DP: Counting Numbers Up to N
Previous: Offline Queries & Mo's Algorithm · Next: Interval DP: Ranges, Splits and the Last Move