3、 char[] target = {'i','f','l','y','t','e','k'}; int count = 0; public int findIflytek (String str) { // write code here char[] chars = str.toCharArray(); dfs(chars, 0, target.length, 0); return count; } public void dfs(char[] chars, int k, int len, int cur){ if (len == k){ count++; return; } for (int i = cur; i < chars.length; i++){ if (chars[i] == target[k]){ dfs(chars, k + 1, len, i + 1); } } }
1 4

相关推荐

点赞 评论 收藏
分享
牛客网
牛客网在线编程
牛客网题解
牛客企业服务