Can any one help out y this code is not working for 1->2->3->4->5 and B =5


#1
ListNode* Solution::partition(ListNode* A, int B) {
ListNode* t =A;
ListNode* t2 =A;
ListNode* t1=A->next;
while(t1!=NULL){
    if(t1->val<B){
        if(t->val>B){
            t2->next = t1->next;
            t1->next = t;
            t = t1;
            t1 = t2->next;
        }
        else{
            t2->next = t1->next;
            t1->next = t->next;
            t->next = t1;
            t=t1;
            t1=t2->next;
        }
    }
    else{
        t2=t1;
        t1=t1->next;
    }
}
return A;

}