Leetcode 763. Partition Labels
Partition the string into the maximum number of contiguous parts such that each letter appears in at most one part, and return the sizes of those parts. This is solved by tracking each character's last occurrence and greedily extending the current segment until it covers all last occurrences of characters seen.
Asked at:
SoFi
Question Timeline
See when this question was last asked and where, including any notes left by other candidates.
Late May, 2026
SoFi
Staff
You are given a string s. We want to partition the string into as many parts as possible so that each letter appears in at most one part. For example, the string "ababcc" can be partitioned into ["abab", "cc"], but partitions such as ["aba", "bcc"] or ["ab", "ab", "cc"] are invalid. Note that the partition is done so that after concatenating all the parts in order, the resultant string should be s. Return a list of integers representing the size of these parts.
Hello Interview Premium
Your account is free and you can post anonymously if you choose.