💯Very Easy Detailed Solution || 🎯Beats 100% of the users || 🎯 Brute Force
Intuition\n Describe your first thoughts on how to solve this problem. \nWe will take two variable to maitain the count of digits at even and odd indices, and t
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nWe will take two variable to maitain the count of digits at even and odd indices, and then will check if both equals or not.\n# Approach\n<!-- Describe your approach to solving the problem. -->\n1. Initialize two variables \'evenSum\' and \'oddSum\' to \'zero\'. These will store the sums of digits at even and odd indices, respectively.\n2. Loop through each character in the string \'num\':\n    - Convert each character to its integer value using \'Character.getNumericValue(num.charAt(i))\'.\n    - If the index \'i is even\', add the digit to \'evenSum\'; if \'i is odd\', add it to \'oddSum\'.\n3. After the loop, compare \'evenSum\' and \'oddSum\'.\n    - If they are equal, return \'true\', indicating that the string is balanced.\n    - Otherwise, return \'false\'.\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n$$O(n)$$\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n$$O(1)$$\n# Code\n```java []\nclass Solution {\n    public boolean isBalanced(String num) {\n        int evenSum = 0, oddSum = 0;\n        for(int i=0; i<num.length(); i++){\n            int ch = Character.getNumericValue(num.charAt(i));\n            if(i%2 == 0){\n                evenSum += ch;\n            }\n            else{\n                oddSum += ch;\n            }\n        }\n        if(evenSum == oddSum){\n            return true;\n        }\n        else{\n            return false;\n        }\n    }\n}\n```
['Math', 'Two Pointers', 'String', 'String Matching', 'Java']