You are viewing a single comment's thread. Return to all comments →
Failed in only one test case...
static List<Integer> freqQuery(List<List<Integer>> queries) { List<Integer> ls = new ArrayList<>(); HashMap<Integer,Integer> hs = new HashMap<>(); for(int i=0;i<queries.size();i++){ int a = queries.get(i).get(0); int b = queries.get(i).get(1); switch(a){ case 1: if(hs.containsKey(b)) hs.replace(b, hs.get(b), hs.get(b)+1); else hs.put(b, 1); break; case 2: if(hs.containsKey(b)){ if(hs.get(b)>1){ hs.replace(b, hs.get(b), hs.get(b)-1); } else hs.remove(b); } break; case 3: if(hs.containsValue(b)) ls.add(1); else ls.add(0); break; } } return ls; }
Seems like cookies are disabled on this browser, please enable them to open this website
Frequency Queries
You are viewing a single comment's thread. Return to all comments →
Failed in only one test case...