엉망이다

import java.util.*;
class Solution {
    public int solution(String skill, String[] skillTrees) {
        int count = 0;
        
        for(String skillTree : skillTrees){
            Set<Character> banSet = new HashSet<>();
            Queue<Character> canQueue = new ArrayDeque<>();
            for(char c : skill.toCharArray()){
                banSet.add(c);
                canQueue.add(c);
            }
            banSet.remove(canQueue.peek());//CBD
            
            boolean isSuccess = true;
            boolean isStart = false;
            for(char c : skillTree.toCharArray()){
                if(!canQueue.isEmpty() && canQueue.peek() == c){
                    canQueue.poll();
                    // banSet.add(canQueue.poll());
                    //if(!canQueue.isEmpty()) banSet.remove(canQueue.peek());
                    continue;
                }
                
                // 2. 배워야 할 스킬이 아닌데, 선행 스킬 목록에 있는 스킬인가?
                // skill 문자열에 포함되어 있는지만 확인하면 됩니다.
                if (skill.indexOf(c) != -1) {
                    // 이 스킬은 선행 스킬이 필요한 스킬인데,
                    // 위 if문에서 걸러지지 않았다는 것은 순서를 어겼다는 의미입니다.
                    isSuccess = false;
                    break;
                }
                // if(isStart && banSet.contains(c)){
                //     isSuccess = false;
                //     break;
                // }
            }
            if(isSuccess) ++count;
        }
        return count;
    }
}
import java.util.Arrays;
 
public class Solution {
    public int solution(String skill, String[] skillTrees) {
        return (int) Arrays.stream(skillTrees)
                .map(s -> s.replaceAll("[^" + skill + "]", ""))
                .filter(skill::startsWith)
                .count();
    }
}