why need to add "()" for i & 1?


  • 0
    public class Solution {
        public int[] countBits(int num) {
            int[] res = new int[num + 1];
            for(int i = 0; i < num + 1; i++)
                res[i] = res[i >> 1] + (i & 1); \\why need to add "()" for i & 1?
            return res;
        }
    }
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.