Skip to content

Instantly share code, notes, and snippets.

@ben-ng
ben-ng / problem-statement.md
Created March 4, 2019 06:03
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:

@ben-ng
ben-ng / rev.c
Created March 4, 2019 06:06
Reverse a linked list in C
while (current != null) {
next = current->next;
current->next = prev;
prev = current;
current = next;
}
head = prev;
object Foo {
var initialized = 0
// This only happens once regardless of how many times Foo.fetch() is called
initialized = initialized + 1
def fetch(): Integer = initialized
}
class Foo {