Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I changed one line to make it work faster.

From the "best" score I was worse than it by 150 or something. Not that I care really.



Looks like one simple change to hashmap may not be the best answer. May I draw the conclusion from your case like that? The best score now went up to almost 3000. I couldn't imagine how many possible ways out there and one of them could be that excellent. Just curious.


Sorted list + binary search was 2000pts and ran much faster than the hashmap solution.


Thank you so much for your info. This is something I'm looking for from the beginning of the discussion.

http://www.algolist.net/Algorithms/Binary_search

This is my original answer! I should not sort the input list though since it's not necessary.

But is string.indexOf() will be even faster?




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: