Easy C++ Solution || Beats 100% 🔥🔥
\n\n# Complexity\n- Time complexity:\n Add your time complexity here, e.g. O(n) \n\n- Space complexity:\n Add your space complexity here, e.g. O(n) \n\n# Code\n
\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\npublic:\n    string inttoBinary(int n){\n        string bin;\n        while(n>0){\n            int digits=n%2;\n            bin=bin+to_string(digits);\n            n=n/2;\n        }\n        cout<<bin;\n        return bin;\n    }\n\n    vector<int> evenOddBit(int n) {\n        \n    vector<int> ans;\n    string s=inttoBinary(n);\n    int odd=0;\n    int even=0;\n\n    for(int i=s.length()-1;i>=0;i--){\n        if(s[i]==\'1\'&& i%2==0){\n            even++;\n        }\n        else if(s[i]==\'1\'&& i%2!=0){\n            odd++;\n        }\n    }\n\n    ans.push_back(even);\n    ans.push_back(odd);\n    \n    return ans;\n    }\n};\n```
['C++']