mirror of
https://github.com/halfrost/LeetCode-Go.git
synced 2025-07-05 00:25:22 +08:00
29 lines
438 B
Go
29 lines
438 B
Go
package leetcode
|
|
|
|
import (
|
|
"github.com/halfrost/LeetCode-Go/structures"
|
|
)
|
|
|
|
// ListNode define
|
|
type ListNode = structures.ListNode
|
|
|
|
/**
|
|
* Definition for singly-linked list.
|
|
* type ListNode struct {
|
|
* Val int
|
|
* Next *ListNode
|
|
* }
|
|
*/
|
|
func deleteNode(node *ListNode) {
|
|
if node == nil {
|
|
return
|
|
}
|
|
cur := node
|
|
for cur.Next.Next != nil {
|
|
cur.Val = cur.Next.Val
|
|
cur = cur.Next
|
|
}
|
|
cur.Val = cur.Next.Val
|
|
cur.Next = nil
|
|
}
|