#3340

Check Balanced String

easy · 82.5% accepted · 139 likes · top 94%

string

⊣ practice⊣ open on leetcode ↗

Description

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.

Solution