public class Solution {

public int findMaxForm(String[] strs, int m, int n) {

int len = strs.length;

List<int[]> freqs = new LinkedList<int[]>();

Arrays.sort(strs,(s1,s2) ->s2.length()-s1.length());
for(int i=0;i<len;i++){
int[] freq = new int[2];
String str = strs[i];
int slen = str.length();
for(int j=0;j<slen;j++){
freq[str.charAt(j)-'0']++;
}
freqs.add(freq);
}
return helper(freqs,0,m,n);
}
public int helper(List<int[]> cand, int pos,int m,int n ){
int len = cand.size();
int dep = Integer.MIN_VALUE;
if(pos>=len) return 0;
for(int i = pos;i<len;i++){
int[] temp = cand.get(i);
m-= temp[0];
n-= temp[1];
if(m>=0&&n>=0){
dep =Math.max(dep,helper(cand,i+1,m,n)+1);
}
m+= temp[0];
n+= temp[1];
}
return dep==Integer.MIN_VALUE?0 : dep;
}

}

hello,I also used DFS,pass 13 test cases. When the input is ["11","11","0","0","10","1","1","0","11","1","0","111","11111000","0","11","000","1","1","0","00","1","101","001","000","0","00","0011","0","10000"]

90

66

I got TLE,do you have any suggestions? I also sorted the string.Thanks.