Advertisement
Guest User

linkedlistremoveelement

a guest
Apr 22nd, 2019
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.54 KB | None | 0 0
  1. Node* deleteValues(Node* head, int value)
  2. {
  3.     Node* current = head;
  4.     while ((*current).value == value && current != NULL)
  5.     {
  6.         head = (*current).next;
  7.         current = (*current).next;
  8.     }
  9.     if (current == NULL)
  10.     {
  11.         return head;
  12.     }
  13.     while ((*current).next != NULL)
  14.     {
  15.         if ((*(*current).next).value == value)
  16.         {
  17.             (*current).next = (*(*current).next).next;
  18.         }
  19.         else
  20.         {
  21.             current = (*current).next;
  22.         }
  23.     }
  24.     return head;
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement