You are viewing a single comment's thread. Return to all comments →
public static List<Integer> matchingStrings(List<String> stringList, List<String> queries) { List<Integer> answer = new ArrayList<>(); for(int i = 0; i < queries.size(); i++){ AtomicInteger count = new AtomicInteger(0); final Integer innerI = new Integer(i); stringList.stream() .filter(sample -> sample.equals(queries.get(innerI))) .forEach(sample -> count.getAndIncrement()); answer.add(count.intValue()); } return answer; }
Seems like cookies are disabled on this browser, please enable them to open this website
An unexpected error occurred. Please try reloading the page. If problem persists, please contact support@hackerrank.com
Sparse Arrays
You are viewing a single comment's thread. Return to all comments →