easyString 0 views

Check Balanced String

You are given a string num consisting of only digits.

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.

Check Balanced String diagram

Example 1

Input: num = "1234"

Output: false

Example 2

Input: num = "24123"

Output: true

Constraints

  • 2 <= num.length <= 100
  • num consists of digits only

Hints

No hints yet.

Companies

No companies reported yet.

Discussion

Sign in to join the discussion.

Loading discussion...

Test results

No test cases yet.