Skip to content

Commit a845950

Browse files
authored
Update DeleteNode.java
1 parent 1ec3711 commit a845950

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

LeetCode/DeleteNode.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
// https://leetcode.com/problems/delete-node-in-a-linked-list/
22
// O(n) solution
33

4+
//Aproach: The question gives access to the node to be deleted instead of the head node. The node to be deleted will not
5+
//be a tail node hence we will set the value of the current node to be that of the next node and set the next of the
6+
//current node to the next of it's next. Simple and efficient solution, 0ms runtime.
7+
48
public class DeleteNode {
59
public class ListNode {
610
int val;

0 commit comments

Comments
 (0)