MCPcopy Create free account
hub / github.com/Tiwarishashwat/InterviewCodes / minExtraChar

Method minExtraChar

ExtraCharactersInAString.java:3–8  ·  view source on GitHub ↗
(String s, String[] dictionary)

Source from the content-addressed store, hash-verified

1class Solution {
2 int dp[] = new int[50];
3 public int minExtraChar(String s, String[] dictionary) {
4 int n = s.length();
5 Arrays.fill(dp,-1);
6 HashSet<String> dictionarySet = new HashSet<>(Arrays.asList(dictionary));
7 return recur(s,dictionarySet,0);
8 }
9 public int recur(String s, HashSet<String> dictionary, int index){
10 if(index==s.length()){ //empty string
11 return 0;

Callers

nothing calls this directly

Calls 1

recurMethod · 0.95

Tested by

no test coverage detected