maracode
\n\n# Complexity\n- Time complexity:\nO(n)\n\n- Space complexity:\nO(1)\n# Code\njava []\nclass Solution {\n    public boolean isBalanced(String num) {\n       
\n\n# Complexity\n- Time complexity:\nO(n)\n\n- Space complexity:\nO(1)\n# Code\n```java []\nclass Solution {\n    public boolean isBalanced(String num) {\n        int sum1=0,sum2=0,len=num.length();\n        for(int i=0,j=1;i<len;i=i+2,j=j+2){\n            sum1+=num.charAt(i)-48;\n            if(j<len)\n            sum2+=num.charAt(j)-48;\n        }\n\n        return sum1==sum2;\n    }\n}\n```
['Java']