← Back to all problems
Medium

Partition Labels

Updated Feb 24, 2026

Problem

Partition string so each letter appears in at most one part; return part lengths.

Constraints

1 <= s.length <= 500

Examples

Example 1

Input: {"s": "ababcbacadefegdehijhklij"}
Output: [9, 7, 8]

Function Signature

def partitionLabels(self, s: str) -> list[int]

How to Submit

Implement a Solution class with a partitionLabels method.

Your method will be called with the input parameters and should return the answer.