Mine
public text v1 · immutable/** Remove a node from the list. **/
public static void remove(int num, Node head) {
Node temp = head;
temp.data = num;
if (head.equals(temp)) {
head = head.next;
return;
}
Node p = head, q = null;
while ((q = p.next) != null) {
if (head.equals(q)) {
p.next = q.next;
return;
}
p = q;
}
}