3 ms·
If you do that your best bet is using a simple long[] (or a direct LongBuffer) and each forest is represent by just a long. Not a stock HashSet(...). Even then
by xxs 12y ago
If you do that your best bet is using a simple long[] (or a direct LongBuffer) and each forest is represent by just a long. Not a stock HashSet(...). Even then the simplest optimization is not adding when the total forest population is inferior to the current best solution.
Rewriting the solution to use a single long smashes the C++ too but yet again, it feels horrid when the real solution is O(1)...