Beats 99% in java and One of the most easiest and simplest logic🔥
Complexity

Time complexity:


O(N)


Space complexity:


O(1)

Code

# Complexity
- Time complexity:
- O(N)


- Space complexity:
- O(1)

# Code
```java []
class Solution {
    public boolean isBalanced(String num) {
        int even = 0, odd = 0;
        for(int i = 0;i < num.length();i++){
            char ch = num.charAt(i);
            if(i % 2 == 0){
                even+=ch - '0';
            }else{
                odd+=ch - '0';
            }
        }

        if(even == odd){
            return true;
        }else{
            return false;
        }
    }
}
```
['Java']