Skip to content

Instantly share code, notes, and snippets.

@Gofilord
Created November 4, 2014 15:17
Show Gist options
  • Save Gofilord/ee2336d3a1ec2fca3b78 to your computer and use it in GitHub Desktop.
Save Gofilord/ee2336d3a1ec2fca3b78 to your computer and use it in GitHub Desktop.
Creating a chain without array
Node<Integer> lastNode = new Node<Integer>(rndVal, null);
Node<Integer> nextNode = new Node<Integer>(rndVal - 1, lastNode);
for (int i = rndVal - 2; i >= 0; i--)
nextNode = new Node<Integer>(i, nextNode);
// print
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment