GoConqr has a new look! Let us know what you think.

Flashcards

Delete a node with a key

Suhas S English 1 card

Cards in this deck (1)

  1. 1Delete all occurrences of a key in a linked listpublic void deleteKey(ListNode head, int key){
    ListNode temp = head;
    ListNode = prev;
    while(temp != null && temp.data ==key){
    head = temp.next;
    temp= head;
    }
    while(temp!=null){
    while(temp!=null && temp.data!=key){
    prev = temp;
    temp= temp.next;
    }
    if(temp == null) return;
    prev.next = temp.next;
    temp = prev.next;
    }
    }

Information

Description
Flashcards on Delete a node with a key, created by Suhas S on 15/02/2018.
Created by
Suhas S
Views
11
Rating

Feedback

What is it about?

What do you think of the new look?

How do you like it?