DEV Community

Discussion on: Fun With Linear Time: My Favorite Algorithm

Collapse
 
gmartigny profile image
Guillaume Martigny

The fact that the sequence A, A, A, B, B, C output C as the leader is a bit underwhelming.
I find the (n/2 + 1) majority limitation a little harsh, but indeed it's an elegant solution to a very common problem.

Collapse
 
healeycodes profile image
Andrew Healey

People will sometimes get stuck on that point and disregard the algorithm. I love that someone out there posted this as a puzzle which is solvable in linear time BUT has this perfect unique solution.

Collapse
 
gmartigny profile image
Guillaume Martigny

If you enjoy perfs related algo puzzles, I really liked solving this one: codingame.com/training/medium/stoc...
Overall, codingame is a great website.

Thread Thread
 
healeycodes profile image
Andrew Healey

This looks neat! Thanks for sharing.