Sponsored
Sponsored
Use these hints if you're stuck. Try solving on your own first.
It can be proven, that if there exists a good subset of rows then there exists a good subset of rows with the size of either 1 or 2.
To check if there exists a good subset of rows of size 1, we check if there exists a row containing only zeros, if it does, we return its index as a good subset.
To check if there exists a good subset of rows of size 2, we iterate over two bit-masks, check if both are presented in the array and if they form a good subset, if they do, return their indices as a good subset.