Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Reverse a linked list in Bash

Given an input.txt that represents a linked list a -> b -> c -> d -> e as a series of nodes with next pointers:

a>b
b>c
c>d
d>e

Reverse the linked list such that the output reads:

e>d
d>c
c>b
b>a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.