Skip to content

Instantly share code, notes, and snippets.

@ben-ng
Created March 4, 2019 06:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ben-ng/b72bc6332e70215ac7c988bdb3f70c93 to your computer and use it in GitHub Desktop.
Save ben-ng/b72bc6332e70215ac7c988bdb3f70c93 to your computer and use it in GitHub Desktop.
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