An open API service indexing awesome lists of open source software.

https://github.com/munificent/linkedlist

Reversing a linked list
https://github.com/munificent/linkedlist

Last synced: 9 months ago
JSON representation

Reversing a linked list

Awesome Lists containing this project

README

          

Apparently, a common programming interview question these days is to write a
function that reverses a linked list. Sometimes they explicitly request a
recursive or iterative solution. Like most bare data structure programming,
getting this right is surprisingly finicky (which is why most of us these days
use nice libraries that provide higher-level abstractions for this).

Just to make sure I'm keeping my tools sharp, I went ahead and implemented this
in all four permutations of:

- Recursive or iterative
- In-place or creating a new list

Unsurprisingly to any functional programmer, the recursive immutable list one is
the most terse.