Count Equal-Distinct Character Partitions
Problem statement
Partition a non-empty lowercase string into one or more non-empty contiguous parts. A partition is valid when every part contains the same number of distinct characters.
Return the number of valid partitions modulo 1,000,000,007.
Function
countEqualDistinctPartitions(value: String) → intExamples
Example 1
value = "aaa"return = 4Every cut pattern is valid because every non-empty part has one distinct character.
Example 2
value = "abca"return = 3The valid partitions are the whole string, four single characters, and ab | ca.
Constraints
1 <= value.length <= 100000valuecontains only lowercase English letters.
Source note: Interview prompt excerpt preserved as source evidence.