Trains the technique from
LeetCode 131Palindrome PartitioningThis is an original problem, written from a brief that listed the technique, the difficulty, the topics, the function shape and the input bounds — none of that problem's wording, examples, hints or editorials. The link is there so you can map your practice onto the standard set.
Same function shape, different story and different numbers.
A jeweller has one long strand of beads. strand is a string of lowercase letters giving the bead colour codes from the clasp outwards, one letter per bead.
She wants to snip the strand into consecutive pieces so that every piece is symmetric: reading a piece from either end must give the same sequence of codes. A piece of one bead counts as symmetric, and every bead must end up in exactly one piece.
Return every way of snipping the strand. Each way is the list of its pieces from the clasp outwards; the ways themselves may come back in any order.
Example 1
Cutting after every bead always works. The only other option is keeping the two b beads together, since "ab" and "abb" are not symmetric.
Example 2
Single beads always work, the middle pair can be kept whole, and the entire strand already reads the same from either end.
Example 3
A single bead admits no cut at all, so there is exactly one way and it is the whole strand.
The values you return may be in any order.
The editor is preloaded with this. It matches the parent problem's shape, so a solution that works here transfers to a judge unchanged.
def strand_cuts(strand: str) -> list[list[str]]:public List<List<String>> strandCuts(String strand)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.