Recent | Popular
#c++ #linked_list #nth_node_from_end
int getNthFromLast(Node *head, int n) { // Your code here Node* front = head; while(front && n--)front = front->next; if(n>0) return -1; Node* rear = head; while(front){ front = front->next; rear = rear->next; } return rear->data; }
Sat May 27 2023 19:54:44 GMT+0000 (Coordinated Universal Time) https://practice.geeksforgeeks.org/problems/nth-node-from-end-of-linked-list/1