Java | O(n) time | Beats 100%
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity: $$O(n)$$\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: $$O(1)$$\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\n  public int[] evenOddBit(int n) {\n    var even = 0;\n    var odd = 0;\n    \n    for (var i=0; n > 0; i++, n /= 2) {\n      if (i % 2 == 0)\n        even += (n & 1);\n      else\n        odd += (n & 1);\n    }\n    return new int[] {even, odd};\n  }\n}\n```
['Java']