Cisco Systems Interview Question: How do you delete a node in a... | Glassdoor

Interview Question

Software Engineer Interview(Student Candidate)

How do you delete a node in a linked list. Code it on the

  white board
Answer

Interview Answer

1 Answer

0

Looking for interview experience sharing and coaching?

Visit AONECODE.COM for ONE-ON-ONE private lessons by FB, Google and Uber engineers.

SYSTEM DESIGN Courses (highly recommended for candidates of FB, LinkedIn, Amazon, Google and Uber etc.),
ALGORITHMS (conquer DP, Greedy, Graph, Advanced Algorithms, Clean Coding)
Cisco question bank sorted by frequency. Get the best preparation within limited time.

Email us aonecoding@gmail.com with any questions. Thanks!

SOLUTION
Delete a given node from linked list
Node removeLast(Node head) {
    Node dummy = new Node(0);
    dummy.next = head;
    Node node = dummy;
    while(node.next.next != null) {
        node = node.next;
    }
    node.next = null;
    return dummy.next;
}

AONECODE.COM on Aug 27, 2018

Add Answers or Comments

To comment on this, Sign In or Sign Up.