easy solution
IntuitionWe need to check if a string of digits is balanced, meaning the sum of digits at even indices is equal to the sum of digits at odd indices. The simples
# Intuition
We need to check if a string of digits is balanced, meaning the sum of digits at even indices is equal to the sum of digits at odd indices. The simplest idea is to traverse the string once, summing digits at even and odd positions separately, and then compare the two sums.

---

# Approach
1. **Traverse the String:**  
   Iterate through each character in the input string.

2. **Convert Characters to Digits:**  
   For each character, subtract `'0'` to convert it from a character to its integer equivalent.

3. **Sum Based on Index Parity:**  
   - If the current index is even (i.e., `i % 2 == 0`), add the digit to the `even` sum.
   - If the index is odd, add the digit to the `odd` sum.

4. **Compare Sums:**  
   After processing the entire string, check if the two sums are equal. If they are, the string is balanced; otherwise, it is not.

---

# Complexity
- **Time Complexity:**  
  \( O(n) \) where \( n \) is the length of the string, since we process each character exactly once.
  
- **Space Complexity:**  
  \( O(1) \) because we only use a few integer variables regardless of the input size.

---

# Code
```cpp
class Solution {
public:
    bool isBalanced(string num) {
        int even = 0, odd = 0;
        
        for (int i = 0; i < num.size(); i++) {
            int digit = num[i] - '0';
            
            if (i % 2 == 0) {
                even += digit;
            } else {
                odd += digit;
            }
        }
        
        return even == odd;
    }
};
```
['C++']