#3597

Partition String

specialist · 745 · lc medium +31 · 58.7% accepted · 69 likes · top 55%

Description

Decompose string s into unique parts using this process:

- Build a segment starting at index 0, appending characters until the current segment is a string not seen before.

- Record the segment as seen and start a new one immediately after.

- Repeat until all of s is consumed.

Return an array segments containing each produced segment in order.

Code

1
2
3