Tap here to switch tabs
Problem
Submissions

Problem: Extra Characters in a String

med
30 min
Try to solve the Extra Characters in a String problem.

Statement

You are given a string s and an array of strings dictionary. You can partition s into one or more non overlapping substrings such that each chosen substring appears in dictionary.

There may be some leftover characters in s that do not belong to any chosen substring.

Return the minimum number of extra characters remaining in s after breaking it up optimally.

Constraints:

  • 1≤1 \leq s.length ≤50\leq 50

  • 1≤1 \leq dictionary.length ≤50\leq 50

  • 1≤1 \leq dictionary[i].length ≤50\leq 50

  • dictionary[i] and s consist of only lowercase English letters

  • dictionary contains distinct words

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Extra Characters in a String

med
30 min
Try to solve the Extra Characters in a String problem.

Statement

You are given a string s and an array of strings dictionary. You can partition s into one or more non overlapping substrings such that each chosen substring appears in dictionary.

There may be some leftover characters in s that do not belong to any chosen substring.

Return the minimum number of extra characters remaining in s after breaking it up optimally.

Constraints:

  • 1≤1 \leq s.length ≤50\leq 50

  • 1≤1 \leq dictionary.length ≤50\leq 50

  • 1≤1 \leq dictionary[i].length ≤50\leq 50

  • dictionary[i] and s consist of only lowercase English letters

  • dictionary contains distinct words