Sparse Arrays

  • + 0 comments
    public static List<Integer> matchingStrings(List<String> strings, List<String> queries) {
    // Write your code here
        List<Integer> finalList = new ArrayList<>();
        Integer tempValue=0;
        for(String s1 :queries){
            for(String s2 :strings){
                if((s1.equals(s2))){
                    tempValue ++;
                }
            }
            finalList.add(tempValue);
            tempValue = 0;
        }
        return finalList;
    }