Skip to content

Comment on A simple clustering algorithm for lists

Comments

Since she doesn't use anything clever to find the index of the rightmost-not-at-end, she could use doubly-linked list which would give O(1) reversal of sublist.

Also, she doesn't really need to keep all consecutive items of the same color, only the number of them, so she could merge consecutive items of same color and add their multiplicities.

At least it's not O(n³).

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.