Split Linked List in Parts - Leetcode 725 - Python

  Рет қаралды 12,383

NeetCodeIO

NeetCodeIO

Күн бұрын

Пікірлер: 22
@aynuayex
@aynuayex 10 ай бұрын
i do not think we have to check if curr exists in the second loop, since it will always exist the edge case is where n < k well in that case it would not even get to the second loop , so with in the loop no need `if not curr: break`
@santanu29
@santanu29 Жыл бұрын
I was able to code it on my own without looking at your video. Watching it now to see if there is a better way.
@abid3801
@abid3801 9 ай бұрын
Bro your explanation is very much fathomable than others. You give the best intuition about the problem.....
@Abdul_bablu
@Abdul_bablu Жыл бұрын
Posted challenge at 5.30...posted video at 6.40 dedication🔥👌
@Md_sadiq_Md
@Md_sadiq_Md Жыл бұрын
Hey babai brahmi Telugu ❤
@jaisaichand6562
@jaisaichand6562 Жыл бұрын
Bramhi dp ❤
@Abdul_bablu
@Abdul_bablu Жыл бұрын
@@Md_sadiq_Md hello bro
@Abdul_bablu
@Abdul_bablu Жыл бұрын
@@jaisaichand6562 ❤️
@technicallytechnical1
@technicallytechnical1 2 ай бұрын
@@Abdul_bablu naku telugu radu
@jamesmnpl
@jamesmnpl Жыл бұрын
Thanks @neetcode. I and few of my friends liked the way you used to lay out the skeleton of the code as in like having the comments listed in order for each task and then filling in those sections with the code . Would love to see that , please do consider adding them it would be immensely helpful. Sorting a rotated array would be one such example from your past videos
@danielsun716
@danielsun716 Жыл бұрын
ef splitListToParts(self, head: Optional[ListNode], k: int) -> List[Optional[ListNode]]: total_length = 0 node = head while node: total_length += 1 node = node.next base_length = total_length // k remainder = total_length % k result = [None for _ in range(k)] i = 0 cur = head while i < k and cur: result[i] = cur partial_size = base_length + (1 if i < remainder else 0) # already have the head in partial list for _ in range(partial_size - 1): cur = cur.next tmp = cur.next cur.next = None cur = tmp i += 1 return result
@peterdavidmora-stevens9185
@peterdavidmora-stevens9185 Жыл бұрын
First? wow, we stan neetcode, updated, finished my Uber interviews that I mentioned previous and went really well! Hopefully I get offer this month :)
@Rutu_More
@Rutu_More Жыл бұрын
Best of Luck !!!!
@alexeyabramov8033
@alexeyabramov8033 Жыл бұрын
Great solution!!! Thanks for posting this. However, I doubt one could come up with such an optimized form on the interview without running the code though. A more explicit implementation is definitely doable.
@messi_codes
@messi_codes Жыл бұрын
SOlved in first go ... thanks to neetcode videos
@nofeah89
@nofeah89 Жыл бұрын
Hi, I really liked what neet code pro is doing, Do you have parity price adjustment for it as I simply cant afford it.
@abisheksaravanakumar745
@abisheksaravanakumar745 Жыл бұрын
you are the goat
@Ishtathuku
@Ishtathuku 2 ай бұрын
We don't even need line 20.
@AdityaRaj-xm6oi
@AdityaRaj-xm6oi Жыл бұрын
can anyone please explain to me how that inner loop is appending elements to sublists, when the append line is out of the inner loop ??
@swauce507
@swauce507 Жыл бұрын
it isnt appending elements, the way it works is that the head of each linked list group is being added to each sublist in res.
@rishitsaboo5979
@rishitsaboo5979 2 ай бұрын
first "for' loop is appending head of partitions not whole linked list and second "for" loop is used for making partitions assigning Null to node
@aazzrwadrf
@aazzrwadrf Жыл бұрын
could be an easy imo.
Longest String Chain - Leetcode 1048 - Python
15:34
NeetCodeIO
Рет қаралды 9 М.
I tricked MrBeast into giving me his channel
00:58
Jesser
Рет қаралды 29 МЛН
the balloon deflated while it was flying #tiktok
00:19
Анастасия Тарасова
Рет қаралды 36 МЛН
My MEAN sister annoys me! 😡 Use this gadget #hack
00:24
Champagne Tower - Leetcode 799 - Python
13:48
NeetCodeIO
Рет қаралды 12 М.
Linked List in Binary Tree - Leetcode 1367 - Python
10:14
NeetCodeIO
Рет қаралды 9 М.
Partition List - Linked List - Leetcode 86
7:40
NeetCode
Рет қаралды 33 М.
Palindrome Linked List - Leetcode 234 - Python
11:06
NeetCode
Рет қаралды 99 М.
Path with Minimum Effort - Leetcode 1631 - Python
14:35
NeetCodeIO
Рет қаралды 15 М.
Extra Characters in a String - Leetcode 2707 - Python
21:11
NeetCodeIO
Рет қаралды 18 М.
Shortest Subarray With OR at Least K II - Leetcode 3097 - Python
18:07
I tricked MrBeast into giving me his channel
00:58
Jesser
Рет қаралды 29 МЛН