For beginners , Beats 100 % of other submissions' runtime.
Intuition\n Describe your first thoughts on how to solve this problem. \nThe problem requires determining if the sum of digits at even indices in a string match
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nThe problem requires determining if the sum of digits at even indices in a string matches the sum of digits at odd indices. The first idea is to iterate through the string, keep track of the sum for both even and odd index positions, and compare them at the end.\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n1) Initialization: You initialize two variables odd and even to 0, which will store the sum of digits at odd and even indices, respectively.\n\n2) Iteration: Loop through the string using an index i. For each character:\nIf i % 2 == 0, it\'s an even index, so you add the digit at that index to even.Otherwise, add the digit at that index to odd.\n\n3)Result: After the loop, return true if even == odd, meaning the sum of digits at even indices equals the sum of digits at odd indices. Otherwise, return false.\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\nThe time complexity is  O(n), where n is the length of the string.\n\nThis is because we need to iterate through each character in the string once.\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\nThe space complexity is O(1), as we are only using a few extra variables (odd, even, n) and not any additional data structures that grow with input size.\n\n# Code\n```cpp []\nclass Solution {\npublic:\n    bool isBalanced(string num) {\n        int n =num.length() ;\n        int odd=0,even=0;\n        for(int i=0;i<n;i++){\n            if(i%2==0)\n                even+=num[i]-\'0\';\n            else\n                odd+=num[i]-\'0\';\n        }\n        return even==odd;\n        \n    }\n};\n```
['C++']