Y
Hacker News
new
|
ask
|
show
|
jobs
by
dgrunwald
144 days ago
That loop isn't N²: if there are long sequences of dashes, every iteration will cut the lengths of those sequences in half. So the loop has at most lg(N) iterations, for a O(N*lg(N)) total runtime.