From 332c517d3af8410336872e5e783c7c6a903f51c9 Mon Sep 17 00:00:00 2001 From: Aditya Yaduvanshi <38696088+adityayaduvanshi@users.noreply.github.com> Date: Mon, 8 Aug 2022 00:52:29 +0530 Subject: [PATCH] Update delete-the-Kth-node-from-the-end.java --- .../delete-the-Kth-node-from-the-end.java | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/algorithms/Java/linked-lists/delete-the-Kth-node-from-the-end.java b/algorithms/Java/linked-lists/delete-the-Kth-node-from-the-end.java index 5688a1f8..e7dae91f 100644 --- a/algorithms/Java/linked-lists/delete-the-Kth-node-from-the-end.java +++ b/algorithms/Java/linked-lists/delete-the-Kth-node-from-the-end.java @@ -20,11 +20,11 @@ head = new_node; } - //this function will delete the kth node in list + /* this function will delete the kth node in list */ void deleteNode(int position) { - //if linked list is empty then return + /* if linked list is empty then return */ if (head == null) return; @@ -65,17 +65,18 @@ { llist.push(p[i]); } - //this will delete the kth node + /* this will delete the kth node */ llist.deleteNode(k-1); - //this will print the linked list after deleteion + /* this will print the linked list after delete the kth node from end */ llist.printList(); } } } -/* Given: 1->2->3->4->5->6 -K=3 +/* Input: +1->2->3->4->5->6 +3 -after deletion: +Output: 1->2->3->5->6 4 is the third last node from the end of linked list. */