LeetCode Explained - Reverse Nodes in K-Groups [HARD]

preview_player
Показать описание
This question is pretty tricky. Thankfully, if we deconstruct it into a rephrased version of a question we already know the answer to it becomes a lot easier.

Getting ready for your next interview? Coding challenges got you frustrated? LeetCode Explained will help you understand all the popular coding interview questions! First we begin by deconstructing the problem into a statement we are able to understand easily.

This problem primarily tests your knowledge on linked lists in the programming language of your choice. Even though this video is in Java, the solution will definitely transfer to all programming languages including: Python, C++, C#, Javascript, etc.

Then after that we start by writing it out just like how we would on a whiteboard. Next, after we come up with a written solution we begin coding. Throughout coding each step gets explained so you don't get confused.

Check out the problem here:

LeetCode Explained - Reverse Nodes in K Groups [HARD]
0:00 Intro
0:26 Whiteboard Walkthrough
4:01 Coding
6:18 Time Complexity
7:13 Outro

Tags: Java, learning to code, leetcode, algorithms, coding interview, coding challenge, programming, learning java, hard programming question, hacker rank, software engineer, software engineering, day in the life of a software engineer, how to code, median, arrays, binary search
Рекомендации по теме
Комментарии
Автор

This is the best solution I've found. So intuitive, simple and straightforward. I also like that you used the simple reverse list, it makes it so much easier to follow.

fbarnea
Автор

What a great video! Thank you for making it! But I think the background music is kind of distracting.

JamesBrodski
Автор

This explanation and code are really the easiest to understand after I tried 4 or 5 different explanations. Thanks a lot!

kittwwang
Автор

Thanks. This was very helpful. I hope your YouTube channel makes it big. I'll be sure to check other videos you've uploaded.

adityakrishna
Автор

Thanks. Which is that background music ?

PuneethSrinivas
Автор

Thanks for your video. I don't think the time complexity is O(nk). The inner while loop to reverse the k elements has already moved the current node to the next k node, so the outside while loop won't iterate through all nodes one by one. Therefore, I think the time complexity is O(n/k * 2k) = O(n). Correct me if I am wrong.

dr_
Автор

Gr8 explanation!
You've earned my subscription.

uddiptakalita
Автор

The most intuitive solution. Thanks Man!

vaib
Автор

Beautiful explanation, I found this explanation better for me to understand and visualize! Thank you!

edwardteach
Автор

Loved your video, extremely easy to understand. Thank you so much for doing it!

tan
Автор

Thank you for this video! It was very easy to follow. Loved it!

tan
Автор

How come root.next become 4 in return statement?
root.next was head which was 1.
I debugged: after the first reverse for (1, 2, 3, 4),
i.e. after prev.next = reverse(tail, K) for (1, 2, 3, 4), root.next becomes 4 from 1
how come it changes root.next from 1 to 4 after the first reverse?

satang
Автор

Thanks for this awesome video @Coding with Conner. You got a new subscriber.

testaccount-umgj
Автор

I almost never comment on YouTube, but I just just want to thank you. Keep the good work.

hishamjuneidi
Автор

what was the need of dummy root node, cant we have just some tmp pointer variable?

priyankarrajgupta
Автор

very good explanation, keep up the good work.

avikchowdhury
Автор

Great job at explaining the approach! The whiteboard explanation was very clear. Just reduce the background sound next time.

parikshit
Автор

It would be much better if there is no BGM.

xiaoyangdong
visit shbcf.ru