Practice Count Number of Balanced Permutations
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Count Number of Balanced Permutations
Problem Statement
You are given a string num. A string of digits is called balanced if the sum of the digits at even indices is equal to the sum of the digits at odd indices. Return the number of distinct permutations of num that are balanced. Since the answer may be very large, return it modulo 10^9 + 7. A permutation is a rearrangement of all the characters of a string.
Source: Count Number of Balanced Permutations on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
num = "123"
2
# Example 2
num = "112"
1
# Example 3
num = "12345"
0
Constraints
Related LeetCode Problems
Practice more problems similar to Count Number of Balanced Permutations.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.