Тёмный

Design a Singly Linked List 

NeetCodeIO
Подписаться 208 тыс.
Просмотров 20 тыс.
50% 1

🚀 Try the problem yourself: neetcode.io/pr...
🥷 Discord: / discord
🐦 Twitter: / neetcode1
🐮 Support the channel: / neetcode
⭐ BLIND-75 PLAYLIST: • Two Sum - Leetcode 1 -...
💡 DYNAMIC PROGRAMMING PLAYLIST: • House Robber - Leetco...
Problem Link: leetcode.com/p...
#neetcode #algorithms #python

Опубликовано:

 

5 окт 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 21   
@HermesSoilder
@HermesSoilder 4 месяца назад
Setting the head to an empty value really makes a huge difference
@hypermeero4782
@hypermeero4782 Год назад
BRING BACK THE OLD THUMBNAIL
@alexzan1858
@alexzan1858 28 дней назад
I dont understand part 6:28. If we want to insert a new head. Shouldnt new_node.next = self.head , and self.head = new_node . So we first point the new head to the old head node, then we assign it as the new head. But now you are inserting a node between the old head and the old heads next node ... ?
@acmethunder
@acmethunder 26 дней назад
Yup. That was frustrating me too when the tests were failing.
@EdenObengNanaKyei
@EdenObengNanaKyei 26 дней назад
we are not doing new_node.next = self.head because remember self.head is the dummy node before the actual head of the linked list. So to point the new node to the old head you have to do new_node.next = self.head.next( this gives the old head)
@grandparick3176
@grandparick3176 Год назад
Well I hope my data structure college course would be helpful xD. But we did it using struct in c++ and not class but I guess the same idea could be applied here.
@anonymoussloth6687
@anonymoussloth6687 Год назад
How did you make a leetcode-like editor on your website? What libraries/tools did you use?
@NeetCodeIO
@NeetCodeIO Год назад
Will make a video on it soon!
@anonymoussloth6687
@anonymoussloth6687 Год назад
@@NeetCodeIO can you also mention how u made the node/tree editor on your website for the roadmap?
@ajinkyax
@ajinkyax 8 месяцев назад
@@anonymoussloth6687 angularjs node graph library
@mohamedelgaili9895
@mohamedelgaili9895 8 месяцев назад
I really need your help on knowing where I can learn the fundamentals of understanding this code. Like, I know the syntax for Python and loops and all that but I don't know anything about classes or objects or even how you could do self.head.next at 4:10. Could you guide me on where I could learn those fundamentals? Any help is appreciated, thank you.
@Kirbylini
@Kirbylini 7 месяцев назад
Learn about classes, superclass/parentclass and then subclass/childclass. Along with inheritance and polymorphism. 1 month late so maybe you already got your answer but if not there's lots of guides or ask chatgpt (what I did at least)
@t-m5678
@t-m5678 Год назад
This is great. Thanks.
@fabersoaks4975
@fabersoaks4975 7 месяцев назад
complexity of appending at ending of the single linked list is On ?
@markokafor7432
@markokafor7432 Год назад
Nice video. Why are you pointing the tail to the head? self.tail = self.head
@Applecitylightkiwi
@Applecitylightkiwi Год назад
Depends on scenario but basically if you create a new node Self.head = new node Self.tail = self.head The second line means that they are both pointing to the new node You could also say self.tail = new node basically in this scenario its the "same"
@hdot2613
@hdot2613 6 месяцев назад
It means we have a dummy value regardless if we're adding/removing from the start or end of a potentially empty linked list.
@sharmagkachannel
@sharmagkachannel 2 месяца назад
when doing the get method in the single linked list, are we not counting head and tail when considering the index in the linked list as per your code if I pass 0 to the get function I will be getting the node value next to the head and not the head. @NeetCodeIO please do reply
@frescosmalls
@frescosmalls Месяц назад
He keeps the dummy head node and never removes/replaces it. I'm not sure why, it seems silly to keep this dummy node (or to even initialize with a dummy node in the first place). So yes, when creating your get method you should start the pointer at the self.head.next as he shows at 3:33 Personally, I think this entire design is flawed in keeping the dummy nodes that serve no real purpose. We should just be initializing an empty list, and if you go to insert a head or tail when there is no current head or tail, both are set to the new node or return some error stating there is no head/tail. Maintaining the dummy node just adds another variable to consider when making changes to the LinkedList that are unnecessary. Interviewers likely would appreciate seeing you handle edge cases such as this anyway.
@ActressFapper
@ActressFapper Год назад
Bro Pls don't change the thumbnails we like the old ones only 😭😭 Old Ones attract me more towards neetcode that i cant say no to them 🥲
Далее
Design Linked List - Leetcode 707 - Python
13:50
Просмотров 27 тыс.
The Problem with Object-Oriented Programming
8:21
Просмотров 150 тыс.
КОТЯТА НАУЧИЛИСЬ ГОВОРИТЬ#cat
00:13
Design a Dynamic Array (Resizable Array)
11:17
Просмотров 37 тыс.
Learn Linked Lists in 13 minutes 🔗
13:24
Просмотров 309 тыс.
Can you steal something that's already free?
11:48
Просмотров 30 тыс.
How I would learn Leetcode if I could start over
18:03
Просмотров 568 тыс.
Programming Languages I used at Google (C++ rant)
6:14
Being Competent With Coding Is More Fun
11:13
Просмотров 89 тыс.
Making an Algorithm Faster
30:08
Просмотров 106 тыс.
Singly Linked Lists Tutorial - What is a Linked List?
13:31
The LeetCode Fallacy
6:08
Просмотров 529 тыс.
ARRAYLIST VS LINKEDLIST
21:20
Просмотров 64 тыс.