Let us initialize first and last nodes of three linked lists 1 ) Linked list of values smaller than x . 2 ) Linked list of values equal to x . 3 ) Linked list of values greater than x .
var smallerHead = null , smallerLast = null ; var greaterLast = null , greaterHead = null ; var equalHead = null , equalLast = null ;