3 ms·
accidentally quadratic. you just want two non-nested loops.
by nullc 2y ago
accidentally quadratic.
you just want two non-nested loops.
- 10000truths 2y agoIt's not accidental. It's optimized to minimize the number of writes necessary to determine whether the reported storage capacity is genuine.
- nullc 2y agoIf it is genuine your quadratic version will perform the same number of writes as the linear time solution. If it is non-genuine what do you care how many writes it will perform? In that case the media is trash anyways. The quadratic test will take an eternity due to the n^2 hashing operations and reads unless it terminates extremely early. If you really have a need to terminate writing early, you could at least perform only a few reads randomly after each write (which will terminate early with high probably not long after you reached the maximum).