LL
LL
this.size = 0; insertLast(val);
} return;
if (tail == null) { }
}
node.next = insertRec(val, index-1, }
node.next);
return node;
public Node find(int value) {
}
Node node = head;
public int deleteLast() {
while (node != null) {
if (size <= 1) {
if (node.value == value) {
return deleteFirst();
return node;
}
}
Node secondLast = get(size - 2);
node = node.next;
int val = tail.value;
}
tail = secondLast;
return null;
tail.next = null;
}
size--;
public Node get(int index) {
return val;
Node node = head;
}
for (int i = 0; i < index; i++) {
public int delete(int index) {
node = node.next;
if (index == 0) {
}
return deleteFirst();
return node;
}
}
if (index == size - 1) {
public int deleteFirst() {
return deleteLast();
int val = head.value;
}
head = head.next;
if (head == null) {
Node prev = get(index - 1);
tail = null;
int val = prev.next.value;
}
prev.next = prev.next.next;
size--;
size--;
return val;
return val;
}
public void display() { }
temp = temp.next; }
} //
https://leetcode.com/problems/merge-
System.out.println("END");
two-sorted-lists/submissions/
}
public static LL merge(LL first, LL second)
private class Node { {
} ans.insertLast(s.value);
} // s = s.next;
https://leetcode.com/problems/remove-
}
duplicates-from-sorted-list
}
public void duplicates() {
while (f != null) {
Node node = head;
ans.insertLast(f.value);
while (node.next != null) {
f = f.next;
if (node.value == node.next.value) {
}
node.next = node.next.next;
while (s != null) {
size--;
ans.insertLast(s.value);
} else {
s = s.next;
node = node.next;
} first.next = second.next;
} }
} } else {
if (row == 0) { }
return; }
// swap return;
if (first == head) { }
prev.next = second;
present = next; }
} list.display();
head = prev; }
first.insertLast(1);
first.insertLast(3);
first.insertLast(5);
second.insertLast(1);
second.insertLast(2);
second.insertLast(9);