Partition Labels

Medium · Greedy · about 15 minutes

Asked at Amazon, Meta, Google.

Cut s into as many consecutive pieces as you can, under the rule that any given letter may only show up inside one piece. Return the lengths of the pieces from left to right.

Related guides