public ListNode partition(ListNode head, int x) {
    	
    	if(null == head || null == head.next) return head;
    	
        ListNode less = new ListNode(0);
        ListNode more = new ListNode(0);
        ListNode temp = null;
        ListNode tempMore = more;
        
        ListNode result = less;
        
        less.next = head;
        
        while(less != null && less.next != null) {
        	if(less.next.val >= x){
        		temp = less.next;
        		less.next = temp.next;
        		temp.next = null;
        		
        		tempMore.next = temp;
        		tempMore = tempMore.next;
        	}else {
        		less = less.next;
        	}
        }
        
        less.next = more.next;
        
        return result.next;
    }