# LeetCode237:Delete Node in a Linked List

Write a function to delete a node (except the tail) in a singly linked list, given only access to that node.

Supposed the linked list is 1 -> 2 -> 3 -> 4 and you are given the third node with value 3, the linked list should become 1 -> 2 -> 4 after calling your function.

/**
* public class ListNode {
*     int val;
*     ListNode next;
*     ListNode(int x) { val = x; }
* }
*/
public class Solution {
public void deleteNode(ListNode node) {
if(node==null)
return;
if(node.next==null)
node=null;
node.val=node.next.val;
node.next=node.next.next;
}
}

• 本文已收录于以下专栏：

## LeetCode 237 : Delete Node in a Linked List

Write a function to delete a node (except the tail) in a singly linked list, given only access to th...
• sunao2002002
• 2015年07月27日 13:54
• 5171

## leetcode 237: Delete Node in a Linked List

leetcode 237: Delete Node in a Linked List PYTHON JAVA C++
• xudli
• 2015年07月15日 14:50
• 16995

## 237. Delete Node in a Linked List [easy] (Python)

• coder_orz
• 2016年05月13日 21:18
• 1401

## LeetCode（237）Delete Node in a Linked List

• fly_yr
• 2015年08月15日 21:32
• 1041

## Leetcode_237_Delete Node in a Linked List

• pistolove
• 2015年08月07日 09:53
• 1295

## leetcode笔记--Delete Node in a Linked List

• u010366748
• 2016年02月19日 14:36
• 239

## leetcode237~Delete Node in a Linked List

Write a function to delete a node (except the tail) in a singly linked list, given only access to th...
• stone_yw
• 2017年03月25日 08:26
• 231

## leetcode237 Delete Node in a Linked List

237. Delete Node in a Linked List Total Accepted: 66681 Total Submissions: 152654 Diffi...
• qq_31186409
• 2016年03月05日 11:06
• 121

## [LeetCode237]Delete Node in a Linked List

• hnxijie
• 2015年11月12日 15:33
• 102

## Delete Node in a Linked List Java LeetCode

Write a function to delete a node (except the tail) in a singly linked list, given only access to th...
• zuoyexingchennn
• 2015年07月31日 12:21
• 900

举报原因： 您举报文章：LeetCode237:Delete Node in a Linked List 色情 政治 抄袭 广告 招聘 骂人 其他 (最多只允许输入30个字)