Please anyone tell what is wrong in B==1 case


#1

/**

  • Definition for singly-linked list.

  • struct ListNode {

  • int val;
    
  • ListNode *next;
    
  • ListNode(int x) : val(x), next(NULL) {}
    
  • };
    /
    ListNode
    Solution::reverseBetween(ListNode* A, int B, int C) {
    if(C==B || (B>C))
    return A;
    ListNode *a=A,*b1=A,*b,*t,*n,*head=A;
    if(B==1)
    {
    C=C-1;;
    while©
    {
    b1=b1->next;
    C–;
    }
    b=b1->next;
    t=a;ListNode *p=b;
    while(t!=NULL)
    {
    n=t->next;
    t->next=p;
    p=t;
    t=n;

    }
    A=p;
    return A;
    }
    B=B-2;
    C=C-1;
    if(B>=0)
    while(B)
    {
    a=a->next;
    B–;
    }
    while©
    {
    b1=b1->next;
    C–;
    }
    b=b1->next;
    b1->next=NULL;
    t=a->next;
    ListNode *p=b;

    while(t!=NULL)
    {
    n=t->next;
    t->next=p;
    p=t;
    t=n;
    }
    a->next=p;
    return A;

}