We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 2d13aed commit de3447dCopy full SHA for de3447d
Course 2 - Data Structures in JAVA/Lecture 8 - Linked Lists II/Delete Node Recursively
@@ -37,3 +37,41 @@ Sample Input 2 :
37
Sample Output 2 :
38
10 20 30 50
39
*/
40
+/*
41
+
42
+ Following is the Node class already written for the Linked List
43
44
+ class LinkedListNode<T> {
45
+ T data;
46
+ LinkedListNode<T> next;
47
48
+ public LinkedListNode(T data) {
49
+ this.data = data;
50
+ }
51
52
53
+*/
54
55
+public class Solution {
56
57
+ public static LinkedListNode<Integer> deleteNodeRec(LinkedListNode<Integer> head, int pos) {
58
+ //Your code goes here
59
+ if (head == null)
60
+ {
61
+ return head;
62
63
64
+ if (pos==0)
65
66
+ head=head.next;
67
68
69
+ else
70
71
+ LinkedListNode<Integer> smallerHead=deleteNodeRec(head.next,pos-1);
72
+ head.next=smallerHead;
73
74
75
76
77
+}
0 commit comments