SHARE
TWEET

Untitled

a guest Dec 7th, 2019 92 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include "list.h"
  2.  
  3. void listReverse(List l) {
  4.     // TODO
  5.     if (l == NULL) {
  6.         return;
  7.     }
  8.    
  9.     Node current = l->head;
  10.     Node prev = NULL;
  11.     Node next = NULL;
  12.    
  13.     while (current != NULL) {
  14.         next = current->next;
  15.         current->next = prev;
  16.         prev = current;  
  17.         current = next;
  18.     }
  19.     l->head = prev;
  20. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top