Created
June 14, 2020 14:31
-
-
Save shubham1710/6496fa8133565bf8bb947f03368276d9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ListNode* removeNthFromEnd(ListNode* head, int n) | |
{ | |
ListNode** t1 = &head, *t2 = head; | |
for(int i = 1; i < n; ++i) | |
{ | |
t2 = t2->next; | |
} | |
while(t2->next != NULL) | |
{ | |
t1 = &((*t1)->next); | |
t2 = t2->next; | |
} | |
*t1 = (*t1)->next; | |
return head; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment