[Java/C++/Python] Calculate the Diff
Time O(n)\nSpace O(1)\n\nJava [Java]\n    public boolean isBalanced(String num) {\n        int diff = 0, sign = 1, n = num.length();\n        for (int i = 0; i 
Time `O(n)`\nSpace `O(1)`\n\n```Java [Java]\n    public boolean isBalanced(String num) {\n        int diff = 0, sign = 1, n = num.length();\n        for (int i = 0; i < n; ++i) {\n            diff += sign * (num.charAt(i) - \'0\');\n            sign = -sign;\n        }\n        return diff == 0;\n    }\n```\n\n```C++ [C++]\n    bool isBalanced(string num) {\n        int diff = 0, sign = 1;\n        for (char i: num) {\n            diff += sign * (i - \'0\');\n            sign = -sign;\n        }\n        return diff == 0;\n    }\n```\n\n```py [Python3]\n\t# O(n) space\n    def isBalanced(self, num: str) -> bool:\n        A = list(map(int, num))\n        return sum(A[::2]) == sum(A[1::2])\n```\n
['C', 'Python', 'Java']