237 title, delete the list of nodes

I, entitled

Here Insert Picture Description1

Second, the idea

Third, the code

public class T0237 {

    public static void main(String[] args) {

    }

    public void deleteNode(ListNode node) {
        node.val = node.next.val;
        node.next = node.next.next;
    }
}

class ListNode {

    int val;
    ListNode next;

    ListNode(int x) {
        val = x;
    }

 }

  1. Source: stay button (LeetCode)
    link: https: //leetcode-cn.com/problems/delete-node-in-a-linked-list
    copyrighted by deduction from all networks. Commercial reprint please contact the authorized official, non-commercial reprint please indicate the source. ↩︎

Published 24 original articles · won praise 0 · Views 104

Guess you like

Origin blog.csdn.net/weixin_45980031/article/details/104117634