You are viewing a single comment's thread. Return to all comments →
I've re-implemented this in Java and it works great!
if(op.equals("add")) { for(int i = 1; i <= contact.length(); i++) { String sub = contact.substring(0, i); Integer currentCount = contacts.get(sub); if(null == currentCount) { contacts.put(sub, 1); } else { contacts.put(sub, 1 + currentCount); } } } else if(op.equals("find")) { Integer maybeCount = contacts.get(contact); int count = null == maybeCount ? 0 : maybeCount; System.out.println(count); }
Seems like cookies are disabled on this browser, please enable them to open this website
Tries: Contacts
You are viewing a single comment's thread. Return to all comments →
I've re-implemented this in Java and it works great!