Topic describes

Given an array nums containing n integers, determine if there are three elements a, B, and c in nums such that a + b + c = 0. Please find all the triples that sum to 0 and are not repeated.

Note: Repeated triples cannot be included in the answer.

Their thinking

Linked list related operations

AC code

var removeNthFromEnd = function (head, n) {
    let dummy = new ListNode()
    dummy.next = head
    let slow = dummy
    let fast = dummy

    while (n) {
        fast = fast.next
        n--
    }
    while (fast.next) {
        slow = slow.next
        fast = fast.next
    }

    slow.next = slow.next.next
    return dummy.next
};

Copy the code

conclusion

  • Pay attention to linked list operations.