Sparse Arrays

  • + 0 comments
    public static List<Integer> matchingStrings(List<String> strings, List<String> queries) {
        // Write your code here
        List<Integer> result = new ArrayList<Integer>();
        int size = strings.size();
        int length = queries.size();
        for(int i=0;i<length;i++){
            int count = 0;
            for(int j=0;j<size;j++){
                if(queries.get(i).equals(strings.get(j))){
                    count++;
                }
            }
            result.add(count);
        }
        return result;
    
        }