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

I don't remember the algorithm exactly and Google isn't yielding any useful results, but I seem to recall that if all the distances are integers (or if you make all the distances integers via scaling/rounding) there is a much faster algorithm that relies on "stepping upward" and considering increasingly larger distances. All I remember is that it's very similar to the same principle that makes radix sort sub-linearithmic.

Anyone know what I'm talking about?



They would certainly have to be bounded integers, right?


Yes, I believe it is something like O(n) where n is the sum of all the distances.

It's probably related to the "pseudopolynomial time subset-sum" algorithm.




Consider applying for YC's Summer 2026 batch! Applications are open till May 4

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

Search: