Optimal Partition of String Problem

Optimal Partition of String Problem — ExecCode Easy DSA Practice

Solve the Optimal Partition of String problem on ExecCode. Free online easy DSA practice in Greedy. Write and run code in Java, C++, Python — no signup required to run.

Problem description

Description You are given a string s, partition the string into one or more substrings such that the characters in each substring are unique. Your task is to compute the required answer and return the minimum number of substrings in such a partition. That is, no letter appears in a single substring more than once. Note that each character should belong to exactly one substring in a partition.

Examples

Input {"s": "eccbbbbdec"}; Output 5. Input {"s": "abcdefg"}; Output 1. Input {"s": "aaaaaaaaaa"}; Output 10

Constraints

1 <= s.length <= 10^5 s consists of only English lowercase letters.

Practice Optimal Partition of String free on ExecCode. Browse DSA problems, topic map, and placement guides.