Hacker News new | ask | show | jobs
by tim_sw 5648 days ago
use an interval tree
1 comments

I took each x axis line segment x(1) -> x(6) for example and hashed it at 1,2,3,4,5,6 and did that for everyone then it would simply be a question of iterating each M point and looking at the hash table

Probably a stupid way to do it but it worked.

I think the issue was that I did not know points == queries

Hashing is indeed the wrong way to go.
Yea, i just wanted to solve it quick so I didn't feel like such a dumb ass. I did it again using your solution and now i see what you mean about scalability because your way is much much faster and more efficient. I had to run my solution on my db server using memcache because it was taking too long and too much memory but yours ran on my laptop.