easy C solution | Runtime Beats 100.00%
IntuitionConsider the even digits as positive numbers and the odd digits and negative numbers. After adding all the digits this way, the result should be zero i
# Intuition\nConsider the even digits as positive numbers and the odd digits and negative numbers. After adding all the digits this way, the result should be zero if the string is balanced. So add all the numbers from the string and rather than deciding whether to add or subtract, simply take the opposite of the number at each step.\n\nCase "1234":\n1 - 2 + 3 - 4 = -2\nnot equal to zero so not balanced\nequivalent to:\n(((((((1 * -1) + 2) * -1) + 3) * -1) + 4) * -1) = -2\n\n# Complexity\n- Time complexity: O(n)\n- Space complexity: O(1)\n\n# Code\n```c []\nbool isBalanced(char* num) {\n  int total = 0;\n  while (*num) {\n    total += \'0\' - *num;\n    total = -total;\n    ++num;\n  }\n  return total == 0;\n}\n```
['Math', 'String', 'C']