Given the string s, divide it into one or more contiguous, nonempty parts whose concatenation is exactly s. A character may occur in only one part: all occurrences of the same character must be contained within that part, so no character can appear in two different parts.
Among all valid partitions, choose the one with the greatest possible number of parts. The partition with the most parts is unique. Return an array containing the sizes of its parts from left to right.
Example 1:
Input: s = "abac"
Output: [3,1]
Explanation: The first part is aba and the second is c. Splitting earlier would place the two a characters in different parts.
Example 2:
Input: s = "qrrqst"
Output: [4,1,1]
Explanation: The first part must contain qrrq because both q occurrences and both r occurrences belong together. The remaining characters can each form their own part.
Example 3:
Input: s = "mnop"
Output: [1,1,1,1]
Explanation: Each character appears once, so every character can be isolated in its own part.
Constraints:
1 <= len(s) <= 10^5 contains only lowercase English lettersEvery character occurrence in s belongs to exactly one partThe returned sizes are positive integers whose sum is len(s)``Need help or want more practice?