-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLLProblem.java
More file actions
49 lines (38 loc) · 998 Bytes
/
LLProblem.java
File metadata and controls
49 lines (38 loc) · 998 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package Collection;
public class LLProblem {
Node head =null;
public Node createNode(String data){
Node obj = new Node();
obj.prev = null;
obj.data = data;
obj.next = null;
return obj;
}
public void add(String name) {
Node newNode = createNode(name);
if (head == null) {
head = newNode;
} else {
Node temp = head;
while (temp.next != null) {
temp = temp.next;
}
temp.next = newNode;
newNode.prev = temp;
}
}
public void printMyLList() {
Node temp = head;
while (temp != null) {
System.out.println("|" +temp.data+ "|");
temp = temp.next;
}
System.out.println("Null");
System.out.println();
}
// public int lengthofLL(){
// Node temp = head;
// int lengthofLL
// }
}
//This is the code that solves linked list problem