Bitmask DP
Learn Bitmask DP (Bit Manipulation, Data Structures & Algorithms) with worked examples, diagrams and interview questions. Free on JavaSchoolLab.
Using a Bitmask as a DP Dimension BITMASK DP extends ordinary DP by adding "which subset of items has been used/visited" as part of the state, encoded as an integer mask. The state becomes dp[mask][...] , and transitions move from one mask to another by setting a bit ( mask | (1 << i) ) when item i gets included.