Skip to content

Instantly share code, notes, and snippets.

@dcapwell
Created September 19, 2016 00:39
Show Gist options
  • Save dcapwell/12a05105680d2337e8439bf26f93a99c to your computer and use it in GitHub Desktop.
Save dcapwell/12a05105680d2337e8439bf26f93a99c to your computer and use it in GitHub Desktop.
// pre-create nodes so its easier to link them together
// add n to first nodes just to make the loop simple
Node[] nodes = new Node[targetLevel + 1];
nodes[0] = n;
for (int i = 1; i <= targetLevel; i++)
nodes[i] = new Node(value, null, nodes[i - 1]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment