Тёмный

Middle of a Linked List (LeetCode 876) | Full Solution with animations | Study Algorithms 

Nikhil Lohia
Подписаться 47 тыс.
Просмотров 7 тыс.
50% 1

Given any type of a list, finding the mid point feels very natural and fundamental. Determining the middle point of a linked list can be a bit tricky as we only have access to the head node. Watch this video to understand how we can use the hare and tortoise algorithm to find the middle of a linked list efficiently. All along with animations and a dry-run of code in JAVA.
Chapters:
00:00 - Intro
- Problem Statement and test-cases
- Straight forward approach
- Hare and tortoise algorithm
- Dry-run of Code
- Final Thoughts
📚 Links to topics I talk about in the video:
Array Data Structure:
Linked Lists:
Traversing a Linked List:
📘 A text based explanation is available at: studyalgorithm...
Code on Github: github.com/nik...
Test-cases on Github: github.com/nik...
📖 Reference Books:
Starting Learn to Code: amzn.to/36pU0JO
Favorite book to understand algorithms: amzn.to/39w3YLS
Favorite book for data structures: amzn.to/3oAVBTk
Get started for interview preparation: amzn.to/39ysbkJ
🔗 To see more videos like this, you can show your support on: www.buymeacoff...
🎥 My Recording Gear:
Recording Light: amzn.to/3pAqh8O
Microphone: amzn.to/2MCX7qU
Recording Camera: amzn.to/3alg9Ky
Tablet to sketch and draw: amzn.to/3pM6Bi4
Surface Pen: amzn.to/3pv6tTs
Laptop to edit videos: amzn.to/2LYpMqn
💻 Get Social 💻
Follow on Facebook at: / studyalgos
Follow on Twitter at: / studyalgorithms
Follow on Tumblr at: / studyalgos
Subscribe to RSS feeds: studyalgorithm...
Join fan mail: eepurl.com/g9Dadv
#leetcode #programming #interview

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

 

10 сен 2024

Поделиться:

Ссылка:

Скачать:

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

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 20   
@jokergotham5865
@jokergotham5865 Год назад
The way of explaining is amazing...... infinite likes
@nikoo28
@nikoo28 Год назад
glad i could help
@anushka7436
@anushka7436 5 месяцев назад
The way you explain is mind blowing. Keep posting such videos!! Thanks a lot
@safar19899
@safar19899 Год назад
Explanation is gold! Thank you my good sir!
@samsulalam3848
@samsulalam3848 Месяц назад
very good explanation and thought. thank you sir
@singhshek58
@singhshek58 10 месяцев назад
nice explanation sir i understood now slow and fast pointer method . Thank you🙂
@oluwatosin001
@oluwatosin001 3 месяца назад
Thank you so much for this explanation and I understood it perfectly
@dhiraj3933
@dhiraj3933 Год назад
Explained Perfectly! Thanks
@sakibsyed7626
@sakibsyed7626 2 года назад
Thanks sir for great explanation
@ymhuang651
@ymhuang651 Год назад
Awesome teaching!
@nikoo28
@nikoo28 Год назад
So happy to read this.
@brinderdhaliwal3570
@brinderdhaliwal3570 8 месяцев назад
Great example
@deliveringIdeas
@deliveringIdeas 2 года назад
Amazing explanation sir!
@yt_goluyadav
@yt_goluyadav 3 месяца назад
sir what if the length of LL is bigger?
@avanishraj386
@avanishraj386 Год назад
while loop looks incorrect as you are saying "or" condition but programmed "and" condition. But, I checked further and confused about why does the program fail when worked with "or " condition?
@nikoo28
@nikoo28 Год назад
it just means that you need to run the while loop until both fastPtr and fastPtr.next are not null
@kalyanamvenumadhav2245
@kalyanamvenumadhav2245 Год назад
Can we use (slowPtr != null) with remaining conditions in while loop I think this will also work May I know why you are not adding (slowPtr != null) in while condition.
@nikoo28
@nikoo28 Год назад
why do you want to add additional conditions?
@kalyanamvenumadhav2245
@kalyanamvenumadhav2245 Год назад
@@nikoo28 we are moving slow pointer along with fast ptr right then why we are not adding slow pointer
@dharmeshkase6003
@dharmeshkase6003 6 месяцев назад
@@kalyanamvenumadhav2245 fast pointer is moving twice the speed isnt it obvious it will reach null first.
Далее
iPhone 16 для НИЩЕБРОДОВ!
00:51
Просмотров 313 тыс.
The Most Elite Chefs Ever!
00:35
Просмотров 6 млн
L16. Delete the middle node of the LinkedList
16:36
Просмотров 39 тыс.
LeetCode was HARD until I Learned these 15 Patterns
13:00
Middle of the Linked List - Leetcode 876 - Python
4:57