less than 1 minute read

You are given a lowercase alphabet string s. Return the number of ways to split the string into two strings such that the number of distinct characters in each string is the same.

Constraints

  • 1 ≤ n ≤ 100,000 where n is the length of s

https://binarysearch.com/problems/Split-String-with-Same-Distinct-Counts

Examples

Example 1

Input

  • s = abaab

Output

  • answer = 2

Explanation

We can split it by "ab" + "aab" and "aba" + "ab"

Solution

Leave a comment