Small, simple, efficient C++ code


#1
ListNode* Solution::partition(ListNode* A, int B) {
if(A->next == NULL) return A;
ListNode* temp = A;
ListNode dummyless(-1);
ListNode* dummylessptr = &dummyless;
ListNode dummymore(-11);
ListNode* dummymoreptr = &dummymore;
while(temp!=NULL){
    if(temp->val < B){
        dummylessptr->next = temp;
        dummylessptr = temp;
    }
    else{
        dummymoreptr->next = temp;
        dummymoreptr = temp;
    }
    temp = temp->next;
}
dummymoreptr->next = NULL;
dummylessptr->next = dummymore.next;
return dummyless.next;

}