I want to iterate on masks such that all combinations of masks with only 1 bit missing first, then all combinations of masks such that 2bits are missing, and so on. This trick I need in TSP and I have used O(2^n) space. Is there any better way to do it in O(1).
Code