Open Ayush-Tibrewal opened 4 months ago
counting in the linked list int count =1; while(temp.next!=null){ temp = temp.next; count++; }
ListNode temp = head; ListNode prev = null ; ListNode next =null; while(temp!=null && c>0){ next = temp.next; temp.next = prev ; prev = temp ; temp = next ;
head.next = temp // idhar head refrence ya pointer rakh dega temp k next par
head = temp.next // idhar temp k next ki jo bhi value hogi wo head mein store ho gi