hi, which libray using in this code i must import node or creating class node!!
class Solution {
/* Returns count of nodes in linked list */
public static int lengthOfList(Node head)
{
int count = 0;
Node temp = head;
while (temp != null) {
count++;
temp = temp.next;
}
return count;
}
public static void main(String[] args)
{
/* Start with the empty list */
LinkedList llist = new LinkedList();
llist.push(1);
llist.push(3);
llist.push(1);
llist.push(2);
llist.push(1);
System.out.println("Count of nodes is = " + lengthOfList(llist.head));
}
}
Course: https://www.educative.io/collection/10370001/5996180548878336
Lesson: https://www.educative.io/collection/page/10370001/5996180548878336/5380990203592704