Do all the things like ++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatarSign Up
Start with a list of 10x10 each.
and crank up the number via an algorithm with a check. if you surpass a certain amount of milliseconds you pass or fail and then display the number.
Looks like you are looking for points that are on the same location? giving two list of 200k points
given by their x,y location (unsorted?)
sounds like a collision detection system.
perhaps you can look for information there.
because the points are just on their x/y coordinates I would just sort them with bucket sort. and then within the buckets I would find matches.
Fast-Nop2952125dWell, you went from O(N²) to O(N) in time, but from O(N) to O(N²) in space.
I would have sorted one of the lists in-place with 'x' as primary key, and 'y' as secondary. That's O(N log N). Then looping through the unsorted list, trying to look up each point in the sorted list using binary search, that's also O(N log N).