Learn the basics of linked lists. Java & Python sample code below.

Check out Brilliant.org ( a website for learning math and computer science concepts through solving problems. First 200 subscribers will get 20% off through the link above.

Special thanks to Brilliant for sponsoring this video.

Find sample code in Python and Java here:

This was #5 of my data structures & algorithms series. You can find the entire series in a playlist here:

Also, keep in touch on Facebook:

Nguồn:https://wijstaanvooronzegrondrechten.org/

Hey everyone! If you are looking for more practice problems for arrays and linked lists, I’d also recommend my Udemy course, “11 Essential Coding Interview Questions” here: https://goo.gl/v35LCa

It’s supposed to be for programming interview questions, but it should be a good resource for improving your problem-solving skills in general.

Anyway, thanks as always for watching! If you don’t want to pay for the course, remember that I have a ton of other free videos right here on this YouTube channel 🙂

def count_nodes(node):

count = 1

if node.next_node is not None: count = count + count_nodes(node.next_node)

return count

Dojo you the ONE!

This helped me understand linked lists really well. Thank you.

Youuu are aaawesome👏👏👏👏…

You're an incredible teacher. Hope these videos never end and stretch across even the most advanced of topics. Very enjoyable.

public static int countNode(ListNode head) {

int count = 1;

while (head.next != null) {

count++;

head = head.next;

}

return count;

}

where is the 'next advanced' video?

static int countNodes(Node head){

int count=0;

Node temp=head;

while(temp!=null){

temp=temp.next;

count++;

}

return count;

}

How did you implement the linked list class? I dont remember seeing you do it but I might have not been paying complete attention. Also is the next video on linked lists out yet?

I learned in 20 minutes what my teachers were trying to teach me for 2 hours…

in C#

int CountNodes(Node head)

{

if(head == null)

return 0;

int count=1;

Node curr = head;

while(curr.next != null){

curr=curr.next;

count++;

}

return count;

}

Hey….I have watched several videos but didn't understand how linked lists exactly worked. After watching ur video I have understood exactly how they work. Great explanation. However, I'm really sad to know that you don't post any videos now. Please let us know why.

Tching tchang tchang tching 😂😂😂

Can I ask u please which app u used to make these visuals

Your explains is awesome!! thank you for your efforts~

I wonder if you can explain react hooks for us. please~~~

I did it recursively:

public int countNodes(Node head) {

int count = 0;

return countNodesHelper(head, count);

}

private int countNodesHelper(Node node, int count) {

if (node != null) {

return countNodesHelper(node.next, count+1);

}

return count;

}

best explaintion

public static int countNodes(Node head) {

int count = 0;

Node temp = head;

if (head != null) {

count++;

while (temp.next != null) {

count++;

temp = temp.next;

}

}

return count;

}

I understand now what node is and head and also data. Tnx for information man, more power to your channel