Created
January 29, 2016 10:04
Revisions
-
berkayk created this gist
Jan 29, 2016 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,30 @@ public void partitionList(Node head, int value) { Node small = null; Node smallItr = null; Node great = null; Node greatItr; while (head != null) { if (head.data < value) { if (smallItr == null) { small = smallItr = head; } else { // Add in between so we don't lose head smallItr.next = head; smallItr = smallItr.next; } } else { // greater than or equal if (greatItr == null) { great = greatItr = head; } else { greatItr.next = head; greatItr = greatItr.next; } } head = head.next; } }