Count Equal-Distinct Character Partitions
Updated
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.
More Infosys Online Assessment questions
- At Most K Jumps with Quadratic Transition CostOA · Seen Nov 2026
- Hiking Club Fastest PaceOA · Seen Nov 2026
- Lowest Common Ancestor with a Changing RootOA · Seen Nov 2026
- Minimum Leaf Path Sum over All RootsOA · Seen Nov 2026
- Split Array to Minimize the Largest SumOA · Seen Nov 2026
- Cherry PickupOA · Seen Nov 2026
- Lexicographically Smallest Grid Path with One Letter ChangeOA · Seen Nov 2026
- Minimum Cost to Supply Water with Wells and PipesOA · Seen Nov 2026
- Minimum Cost to Tile a Strip with Widths 1, 2, and 3OA · Seen Nov 2026
- Minimum Rounds to Complete All TasksOA · Seen Nov 2026
Similar questions at other companies
- Max Subarray Filled With ZerosGoogle · OAGoogle interview questions
- Long BreakWeRide · OAWeRide interview questions
- New 21 Game ProbabilityUiPath · PHONE SCREEN
- Maximum Earnings Across WarehousesAmazon · ONSITE INTERVIEW
- API Shield with Two Rolling LimitsGraviton · OA
- Expected Steps Until a Random Walk Gets Far From ZeroOptiver · OAOptiver interview questions
- Largest Consistent Visiting GroupAuxoAI · OA
- Delete K Subsets for Maximum ScoreRubrik · OARubrik interview questions
- Safest Shortest Path Through a GridSnowflake · OASnowflake interview questions
- Part 2: Batch Access ReviewScale AI · OAScale AI interview questions