5 hands-on exercises and 5 find-the-bug challenges for the Bitmask Dynamic Programming lesson. Every one is checked automatically in the browser — write the code, run it, and the tests tell you what still fails.
Report how many subsets four items have.
Report whether bit two is set in the mask five.
Set bit one in the mask four and show the result.
Show the mask with all three bits set.
Count how many items the mask eleven contains.
The number of subsets is two to the n, not n squared.
Bit two is 1 shifted twice, not the value two.
Ready to write the code?
The editor, the automatic checks and the worked solutions open up with an account.
Open the workspaceXOR toggles a bit, so adding twice removes it again.
All n bits set is two to the n minus one.
Two to the thirty is a billion states, far past what fits.