27 ms·
boolean checkExactlyOneBitSet(int num) { return (num & (num - 1)) == 0; } That looks like it'll fail when num == 0. I think it should be: return num && ((
by gwilliams 7y ago
boolean checkExactlyOneBitSet(int num) {
return (num & (num - 1)) == 0;
}
That looks like it'll fail when num == 0. I think it should be:
return num && ((num & (num - 1)) == 0);
- deleted 7y ago[deleted]
- anentropic 7y agomaybe posting a github issue would be helpful