You are viewing a single comment's thread. Return to all comments →
if(hash.get(num)<=1) hash.remove(num); else hash.put(num,hash.get(num)-1);
Change this snippet to : if(hash.containsKey(num)){ hash.put(num,hash.get(num)-1); if(hash.get(num)==0) hash.remove(num); }
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 →
if(hash.get(num)<=1) hash.remove(num); else hash.put(num,hash.get(num)-1);