As the post says, this implementation might not be the most performant. However, performance would probably be good enough by simply replacing the Vec with a VecDeque. Not sure if this wasn't used for the purpose of teaching or because it would become too trivial.
As the post says, this implementation might not be the most performant. However, performance would probably be good enough by simply replacing the
Vec
with a VecDeque. Not sure if this wasn't used for the purpose of teaching or because it would become too trivial.I agree that using VecDeque is a great idea!