Problem
You get a string s of lowercase English letters. Cut s into as many parts as possible, so that each letter appears in one part only.
The parts keep the order of s, so when you join them again, you get s. Return a list with the length of each part, from left to right.
Example 1
- Input:
- s = "abacdcef"
- Output:
- [3,3,1,1]
- Explanation:
- The parts are
aba,cdc,eandf. More parts would put one letter into two parts.
Example 2
- Input:
- s = "xyzzyx"
- Output:
- [6]
- Explanation:
- The letter
xis at the first and the last position, so the full string must be one part.
Constraints
- 1 <= s.length <= 500
- s contains only lowercase English letters.
SysRound wrote this statement. A reference solution checks every example.
Related questions
Continue with questions that share topics or the same question type.
Sources · 1 reference
These records explain where the question appears. A company tag or candidate report does not guarantee a future interview question.
Hello Interview · 1 record
SoFi
Leetcode 763. Partition Labels
Reported May 22, 2026 · 1 source report
STAFF
Source snapshot: Nov 12, 2026
View source