easy solution | beats 100%
Intuition\nTo determine if the string num is balanced, we need to separate the digits at even and odd indices, calculate the sum of each group, and check if the
# Intuition\nTo determine if the string `num` is balanced, we need to separate the digits at even and odd indices, calculate the sum of each group, and check if they are equal.\n\n# Approach\n1. Initialize `even` and `odd` sums to zero.\n2. Traverse each character in the string:\n   - If the index is even, add the integer value of the digit to `even`.\n   - If the index is odd, add the integer value of the digit to `odd`.\n3. Finally, compare the sums of `even` and `odd` indices. If they are equal, return `true`; otherwise, return `false`.\n\n# Complexity\n- **Time complexity**: $$O(n)$$, where $$n$$ is the length of the string, as we iterate through the string once.\n- **Space complexity**: $$O(1)$$, as only a few variables are used.\n\n# Code\n```cpp []\nclass Solution {\npublic:\n    bool isBalanced(string num) {\n        int even = 0, odd = 0 ;\n        for (int i=0; i<num.size(); i++){\n            if (i & 1) odd += (num[i] - \'0\') ;\n            else even += (num[i] - \'0\') ;\n        }\n        return even == odd ;\n    }\n};\n```
['C++']