We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
publicstaticList<Integer>matchingStrings(List<String>strings,List<String>queries){// Write your code hereHashMap<String,Integer>map=newHashMap<>();for(inti=0;i<strings.size();i++){Strings=strings.get(i);if(map.containsKey(s)){map.put(s,map.get(s)+1);}else{map.put(s,1);}}System.out.println(map);List<Integer>res=newArrayList<>();for(inti=0;i<queries.size();i++){if(map.containsKey(queries.get(i))){res.add(map.get(queries.get(i)));}else{res.add(0);}}returnres;}
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Sparse Arrays
You are viewing a single comment's thread. Return to all comments →