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 Жыл бұрын
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.
@abid38019 ай бұрын
Bro your explanation is very much fathomable than others. You give the best intuition about the problem.....
@Abdul_bablu Жыл бұрын
Posted challenge at 5.30...posted video at 6.40 dedication🔥👌
@Md_sadiq_Md Жыл бұрын
Hey babai brahmi Telugu ❤
@jaisaichand6562 Жыл бұрын
Bramhi dp ❤
@Abdul_bablu Жыл бұрын
@@Md_sadiq_Md hello bro
@Abdul_bablu Жыл бұрын
@@jaisaichand6562 ❤️
@technicallytechnical12 ай бұрын
@@Abdul_bablu naku telugu radu
@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 Жыл бұрын
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 Жыл бұрын
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 Жыл бұрын
Best of Luck !!!!
@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 Жыл бұрын
SOlved in first go ... thanks to neetcode videos
@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 Жыл бұрын
you are the goat
@Ishtathuku2 ай бұрын
We don't even need line 20.
@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 Жыл бұрын
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.
@rishitsaboo59792 ай бұрын
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