Skip to content
Programmingoneonone
Programmingoneonone
  • Engineering Subjects
    • Internet of Things (IoT)
    • Digital Communication
    • Human Values
  • Programming Tutorials
    • C Programming
    • Data structures and Algorithms
    • 100+ Java Programs
    • 100+ C Programs
    • 100+ C++ Programs
  • Solutions
    • HackerRank
      • Algorithms Solutions
      • C solutions
      • C++ solutions
      • Java solutions
      • Python solutions
    • Leetcode Solutions
    • HackerEarth Solutions
  • Work with US
Programmingoneonone
Programmingoneonone

Leetcode Delete Node in a Linked List problem solution

YASH PAL, 31 July 202420 January 2026

In this Leetcode Delete Node in a Linked List problem solution Write a function to delete a node in a singly-linked list. You will not be given access to the head of the list, instead, you will be given access to the node to be deleted directly. It is guaranteed that the node to be deleted is not a tail node in the list.

Leetcode Delete Node in a Linked List problem solution

Leetcode Delete Node in a Linked List problem solution in Python.

def deleteNode(self, node: ListNode, n: int) -> None:
    while node.val != n:
        node = node.next
    node.val = node.next.val
    node.next = node.next.next
    return

Delete Node in a Linked List problem solution in Java.

class Solution {
    public void deleteNode(ListNode node) {
        while(node.next.next!=null)
        {
            node.val=node.next.val;
            node=node.next;
        }
        node.val=node.next.val;
        node.next=null;
    }

Problem solution in C++.

class Solution {
public:
void deleteNode(ListNode* node) {
*node = *(node->next);
}
};

Problem solution in C.

void deleteNode(struct ListNode* node) {

struct ListNode *temp=node;
struct ListNode *temp1=NULL;

while(temp->next != NULL)
{
    temp->val=temp->next->val;
    temp1=temp;
    temp=temp->next;
}
temp1->next=NULL;
free(temp);
}

coding problems solutions Leetcode Problems Solutions Leetcode

Post navigation

Previous post
Next post

Leave a Reply

Your email address will not be published. Required fields are marked *

Programmingoneonone

We at Programmingoneonone, also known as Programming101 is a learning hub of programming and other related stuff. We provide free learning tutorials/articles related to programming and other technical stuff to people who are eager to learn about it.

Pages

  • About US
  • Contact US
  • Privacy Policy

Practice

  • Java
  • C++
  • C

Follow US

  • YouTube
  • LinkedIn
  • Facebook
  • Pinterest
  • Instagram
©2026 Programmingoneonone | WordPress Theme by SuperbThemes