Short and simple in Java(2595)
Code\njava []\nclass Solution {\n    public int[] evenOddBit(int n) {\n        //using tobinarystring method\n        int[] res= new int[2];\n        String bit
# Code\n```java []\nclass Solution {\n    public int[] evenOddBit(int n) {\n        //using tobinarystring method\n        int[] res= new int[2];\n        String bit=Integer.toBinaryString(n);//onverting to binary\n        for(int i=bit.length()-1,k=0;i>=0;i--){//y k=0 is cause the i moves from r to l\n            if(i%2==0){\n                if(bit.charAt(k++)==\'1\'){\n                    res[0]+=1;//increment even\n                }\n            }\n            else{\n                if(bit.charAt(k++)==\'1\'){\n                    res[1]+=1;//increment odd\n                }\n            }\n        }\n        return res;\n    }\n}\n```\n# Code\n```java []\nclass Solution {\n    public int[] evenOddBit(int n) {//without ToBinaryString()\n        //converting to binary and then finding val\n        Stack<Integer> stack= new Stack<>();\n        while(n>0){\n            stack.push(n%2);//the remainder is pushed in\n            n/=2;//later n val updated\n        }\n        int[] arr= new int[stack.size()];//creating an array to store vals\n        int x=0;\n        while(!stack.isEmpty()){\n            arr[x++]=stack.pop();//we will have the binary val in array format\n        }\n        int ind=0;\n        int even=0;//counting even\n        int odd=0;//countin odd\n        for(int i=arr.length-1;i>=0;i--){\n            if(ind%2==0){\n                if(check(arr[i])) even++;//checking if even updating \n                ind++;\n        }   else{\n                if(check(arr[i])) odd++;//checking if odd updating \n                ind++;\n            }\n        }\n        int[] res=new int[2];\n        res[0]=even;//assigning\n        res[1]=odd;\n        return res;\n    }\n    //check method\n    public static boolean check(int i){\n        return i==1;\n    }\n}\n```
['Array', 'String', 'Stack', 'Java']