Practice Number of Good Ways to Split a String
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Medium#1525
LeetCode ProblemNumber of Good Ways to Split a String
Problem Statement
You are given a string s. A split is called good if you can split s into two non-empty strings sleft and sright where their concatenation is equal to s (i.e., sleft + sright = s) and the number of distinct letters in sleft and sright is the same. Return the number of good splits you can make in s.
Source: Number of Good Ways to Split a String on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
Input
s = "aacaba"
Output
2
# Example 2
Input
s = "abcd"
Output
1
Constraints
1 <= s.length <= 10^5
s consists of only lowercase English letters.
Related LeetCode Problems
Practice more problems similar to Number of Good Ways to Split a String.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.