FastPrepPartition Labels

Partition Labels

Bloomberg LP logoBloomberg LP● MediumNEW GRADPHONE SCREEN
Learn

Problem statement

Split text into as many nonempty contiguous parts as possible so each distinct character appears in at most one part. Return the part lengths from left to right.

Function

partitionLabels(text: String) → int[]

Examples

Example 1

text = "abcabcabdefffedgijhkij"return = [8,7,1,6]

The maximal parts are abcabcab, defffed, g, and ijhkij.

Constraints

  • 0 <= text.length <= 10^5.
  • The text contains lowercase English letters.

More Bloomberg LP problems

See Bloomberg LP hiring insights
public int[] partitionLabels(String text) {
  // Write your code here.
}
text"abcabcabdefffedgijhkij"
expected[8,7,1,6]
Checking account…