You are viewing a single comment's thread. Return to all comments →
java
Map<String, Integer> m = new HashMap<String, Integer>(); for (int i = 0; i < stringList.size(); i++) { String val = stringList.get(i); if (m.containsKey(val)) { m.put(val, m.get(val) + 1); } else { m.put(val, 1); } } List<Integer> res = new ArrayList<Integer>(queries.size()); for (int j = 0; j < queries.size(); j++) { Integer newVal = m.getOrDefault(queries.get(j), 0); res.add(newVal); } return res;
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 →
java