Linked List: 新增資料、刪除資料、反轉Linked List

http://alrightchiu.github.io/SecondRound/linked-list-xin-zeng-zi-liao-shan-chu-zi-liao-fan-zhuan.html

Singly Linked List

Doubly Linked List

  1. Delete a node
Node deleteNode(Node head, int d) {
    Node current = head;

    if (current->data == d) {
        return head->next;
    }
    while (current->next != NULL) {
        if (current->data == d) {
            current->next = current->next->next;
        }
        current = current->next;
    }
    return head;
}

results matching ""

    No results matching ""