Check Balanced String - Practice Coding | SlaveCode
0
0123456789
0
0123456789
:
0
0123456789
0
0123456789
3340. Check Balanced String
Easy
10 Points
String
You are given a string num consisting of only digits. A string of digits is called balanced if the sum of the digits at even indices is equal to the sum of digits at odd indices.
Return true if num is balanced, otherwise return false.
Examples
Example 1
Input: num = "1234"
Output: false
Explanation:
Example 2
Input: num = "24123"
Output: true
Explanation:
Constraints
2 <= num.length <= 100
num consists of digits only
3340. Check Balanced String
Easy
10 Points
String
You are given a string num consisting of only digits. A string of digits is called balanced if the sum of the digits at even indices is equal to the sum of digits at odd indices.
Return true if num is balanced, otherwise return false.