mediumHash TableSimulationStringTrie 0 views

Partition String

Given a string s, partition it into unique segments according to the following procedure: Return an array of strings segments, where segments[i] is the ith segment created.

Given a string s, partition it into unique segments according to the following procedure:

Return an array of strings segments, where segments[i] is the ith segment created.

Partition String diagram

Example 1

Input: s = "abbccccd"

Output: ["a","b","bc","c","cc","d"]

Explanation: Hence, the final output is ["a", "b", "bc", "c", "cc", "d"] .

Example 2

Input: s = "aaaa"

Output: ["a","aa"]

Explanation: Hence, the final output is ["a", "aa"] .

Constraints

  • 1 <= s.length <= 10^5
  • s contains only lowercase English letters.

Hints

Companies

No companies reported yet.

Discussion

Sign in to join the discussion.

Loading discussion...

Test results

No test cases yet.