LC 763 — Problem

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. Return a list of integers representing the size of these parts.

Input: s = “ababcbacadefegdehijhklij”
Output: 978
Explanation: The partition is “ababcbaca”, “defegde”, “hijhklij”. Each letter appears in at most one part.
Input: s = “eccbbbbdec”
Output: [10]

Constraints: 1 ≤ s.length ≤ 500 · s consists of lowercase English letters

Try cutting the string into partitions. Tap a gap between characters to place a cut.

Each partition must contain ALL occurrences of every character inside it. Find where you CAN safely cut "ababcbacadefegdehijhklij".

FIG. 1 — STRAIGHT CUTS, RUBBER-BAND VIOLATIONS
a0b1a2b3c4b5a6c7a8d9e10f11e12g13d14e15h16i17j18h19k20l21i22j23
Failed cuts: 0Valid cuts: 0

Tap the gaps between characters to place cuts. Find at least 2 invalid cuts and 1 valid cut to continue.