Answers for "last index of linkedList in c"

C
1

last index of linkedList in c

typedef struct Node {
  struct Node* next;
  int val;
} Node;



/*
The function passes through every node until it reaches the node pointing to
NULL.
input: The list pointer
output: The last node in the list.
*/
Node* getLastNode(Node* list)
{	
  	if(list)
    {
      while(list->next)
      {
       list = list->next; 
      }
    }
    return list;
}
Posted by: Guest on July-13-2020

Code answers related to "C"

Browse Popular Code Answers by Language