- document/comment your code. In the code.
- re-checking
.nextin the second loop is unusually defensive - do not have a comment repeat what a statement "does" (
reset node to point to head):
have it illuminate what is achieved/what-for/why something is done (the way it is) - the ruby way to have a statement executed, say,
middletimes may bemiddle.times do node = node.next
(Eyeballing remove_middle_node, it uses O(1) additional space and Θ(n) time.)