Bitmask
LeetCode 996: Number of Squareful Arrays
·3 mins
LeetCode
Hard
Dynamic-Programming
Bitmask
Backtracking
Math
Hash-Table
LeetCode 996 note: with n at most 12, use bitmask DP: dp[mask][last] = permutations using the set mask and ending with last; dedupe by using equal values in index order
LeetCode 2376: Count Special Integers
·2 mins
LeetCode
Hard
Dynamic-Programming
Digit-Dp
Math
Bitmask
LeetCode 2376 note: digit DP with state (pos, tight, started, mask); the mask records used digits, and leading zeros must not mark 0 as used