Split Linked List in Parts | Clean | Simple Code | Dry Run | Leetcode - 725 | codestorywithMIK

  Рет қаралды 8,555

codestorywithMIK

codestorywithMIK

Күн бұрын

Пікірлер: 70
@saquibabbas1709
@saquibabbas1709 Жыл бұрын
Watching #MikSir while travelling #WellExplained 🔥 🔥
@codestorywithMIK
@codestorywithMIK Жыл бұрын
Means a lot 😍. Btw, hats off to your dedication ❤
@thekindspill
@thekindspill Жыл бұрын
woooahh 🔥
@EB-ot8uu
@EB-ot8uu 7 ай бұрын
itni dedication mujhe bhi chaie bhai
@chaitanya812
@chaitanya812 Жыл бұрын
watching even after solving .. all thanks to you
@codestorywithMIK
@codestorywithMIK Жыл бұрын
Means a lot. Thank you 🙏😇❤️
@abhishekverma7604
@abhishekverma7604 Жыл бұрын
now my brain crafts story for every problem,now i look up any problem from different perspective.. this channel will hit mark what no DSA channel has ever done before...
@codestorywithMIK
@codestorywithMIK Жыл бұрын
It means a lot to me. Thank you so much for your kind words ❤️😇🙏
@dhairyachauhan6622
@dhairyachauhan6622 Жыл бұрын
Thank you bhaiya till now no one had taught recursion so well, making recursion trees like you do. Now i am so good with it i solved todays question on my own, maybe not in the most efficient way but i did it in o(n) time and space using resursion. Only problem is code is not clean 😅😅 class Solution { public: int findLen(ListNode*head){ int len = 0; while(head!= NULL){ head = head->next; len++; } return len; } vector ans; void solve(ListNode*head,int k,int divisions,int extra){ if(k == 0){ coutnext; } if(curr){ curr->next = NULL; } ans.push_back(head); solve(nextHead,k-1,divisions,extra); } vector splitListToParts(ListNode* head, int k) { // step 1 find the length of linked list if(head == NULL){ while(k>0){ ans.push_back(NULL); k--; } return ans; } int len = findLen(head); int divisions = 1; int extra = 0; if(k
@sachinmohanty4577
@sachinmohanty4577 Жыл бұрын
bhai thoda thought process share karoge recursion kaise aaya dimag mei starting se? i am asking because LL ke sawal mei itertaive way hi dimag mei aata hei mostly mujhe. waiting for you response! thank you!!
@wearevacationuncoverers
@wearevacationuncoverers Жыл бұрын
wow bro
@gui-codes
@gui-codes 2 ай бұрын
one of the best explanations man. You easily beat other youtubers in explanation skills.
@shauryan23
@shauryan23 Жыл бұрын
Recently Discovered your channel brother. And loved your content. Keep posting 🔥🔥🔥
@codestorywithMIK
@codestorywithMIK Жыл бұрын
Welcome to my small channel. Thank you so much for watching and your kind words ❤️❤️🙏🙏😇😇
@thegreekgoat98
@thegreekgoat98 2 ай бұрын
Kya aadmi hai yaar.. kya samjhata h...
@codestorywithMIK
@codestorywithMIK 2 ай бұрын
Hope my video helps ❤️🙏
@thekindspill
@thekindspill Жыл бұрын
I never thought I would be able understand DSA with so much clarity. It's because of you #MIK Thanks a lot
@mohithadiyal6083
@mohithadiyal6083 Жыл бұрын
Simply superrrr 😊
@rounaq_khandelwal
@rounaq_khandelwal Жыл бұрын
ye remainder nodes wla concept i do remember, u taught in past in some other video, due to which I could solve this qn, I was so happy to see ki whi concept apply ho rha!! #mikBhaiRocks
@codestorywithMIK
@codestorywithMIK Жыл бұрын
So glad to know 😇🙏❤️
@AdarshTiwari-r5f
@AdarshTiwari-r5f 8 ай бұрын
great storytelling sir hats off to you sir
@EB-ot8uu
@EB-ot8uu 7 ай бұрын
Insane level of teaching
@aizad786iqbal
@aizad786iqbal 2 ай бұрын
amazing, just watching your story helps me write the code, I always get confused and think of while loops only when it comes to trees linked list etc... which makes the code logic complex class Solution { public ListNode[] splitListToParts(ListNode head, int k) { int n = 0; ListNode temp = head; while(temp != null){ n++; temp=temp.next; } int rem = n%k; int parts = n/k; ListNode[] result = new ListNode[k]; ListNode curr = head; ListNode prev = null; if(head == null){ return result; } for(int i=0; i
@himanshuyadav0600
@himanshuyadav0600 2 ай бұрын
Already solved but still watching sir ..🔥🔥🔥. Sir please try to upload weekly contest solutions also. Atleast last 2 questions of contest . It would be great. Thank you #MikSir
@codestorywithMIK
@codestorywithMIK 2 ай бұрын
Maximum Number of Moves to Kill All Pawns | Step By Step Detailed | Leetcode 3283 | codestorywithMIK kzbin.info/www/bejne/pqvCpJ-Cir5qsJI
@AlishaKhan-ww3io
@AlishaKhan-ww3io Жыл бұрын
thank you for making every problem look easy 😃
@ugcwithaddi
@ugcwithaddi Жыл бұрын
Masterpiece explanation. I was able to code it in between from your story. Thanks a lot ❤
@utkarshjain6755
@utkarshjain6755 Жыл бұрын
God level explaination sir ♥
@abhaykumar4680
@abhaykumar4680 Жыл бұрын
Happy Teacher's day sir
@codestorywithMIK
@codestorywithMIK Жыл бұрын
Thank you ♥️😊 Happy Teachers’ Day to you too
@pintushkumar7542
@pintushkumar7542 Жыл бұрын
Nice Explanation sir Sir gfg ka POTD ka bhi video banaye Aise me sir daily ka do problem solve hoga
@JoyAcharyatvl
@JoyAcharyatvl Жыл бұрын
Awesome bhai. Thanks.
@MohammedHasmi577
@MohammedHasmi577 2 ай бұрын
Sir cant describe in worrs u r just amazing teacher 🔥🔥🔥
@codestorywithMIK
@codestorywithMIK 2 ай бұрын
Means a lot ❤️🙏😇
@anuppatankar4294
@anuppatankar4294 Жыл бұрын
GREAT VIDEO 🔥
@vedantdhole3422
@vedantdhole3422 6 ай бұрын
best explanation
@GAURAVKUMAR-dr4mq
@GAURAVKUMAR-dr4mq Жыл бұрын
Your explanation is quite good. Can you teach on live session on KZbin or somewhere else.
@AkOp-bf9vm
@AkOp-bf9vm 2 ай бұрын
MY CODE class Solution { public: int findLen(ListNode*head){ int cnt=0; while(head){ head=head->next; ++cnt; } return cnt; } ListNode* divide(int each,ListNode*&temp){ if(each==0 || temp==NULL) return NULL; ListNode* head = temp; for (int i = 0; i < each - 1; ++i) { temp = temp->next; } if (temp) { ListNode* nxtNode = temp->next; temp->next = nullptr; temp = nxtNode; } return head; } vector splitListToParts(ListNode* head, int k) { vector result; ListNode*temp=head; int len=findLen(head); int each=len/k; int extra=len%k; ListNode*guest=NULL; for(int i=0;i
@Tejaswi-xd4re
@Tejaswi-xd4re Жыл бұрын
Sir when will leetcode question video come for beginners
@UtkarshPatel-v9o
@UtkarshPatel-v9o Жыл бұрын
nice explanation bhaiya
@codestorywithMIK
@codestorywithMIK Жыл бұрын
Thank you 😇🙏
@mileshsoni5016
@mileshsoni5016 Жыл бұрын
bhai please 1 video leetcode 1007 pe bana do bht confusion h ki kyu wo dp se solve ni hoga, Great explanation BTW abhi tw bht aage jana h :)
@amanverma5278
@amanverma5278 Жыл бұрын
Good explantion...
@codestorywithMIK
@codestorywithMIK Жыл бұрын
Glad you liked it 😊♥️
@TheBusaSinger
@TheBusaSinger Жыл бұрын
Helpful topic! Thanks!
@dayashankarlakhotia4943
@dayashankarlakhotia4943 Жыл бұрын
class solution { public List Node []split List To Part(List Node head,int k){ List Node cur =head; List Node []ans=new List Node [k]; int len=0,ptr=0; while (cur!=null){ len++; cur =cur. next; } int remian =len %k, int part len =len/k; cur =head; while (cur!=null){ ans[ptr++]= cur; int current len =part len-1+((remian-->0)?1:0); for(int i=0;i
@AnandKumar-kz3ls
@AnandKumar-kz3ls Жыл бұрын
great explanation here is my code class Solution { public: vector splitListToParts(ListNode* head, int k) { int n=0; ListNode* t=head; while(t){ t=t->next; n++; } vector result(k,nullptr); ListNode* next_node; int i=0; int rem=(n%k); int size=0; while(head){ size = n/k; if(rem) size++; ListNode* start = head; while(--size > 0 && head->next){ head=head->next; } result[i]=start; next_node=head->next; head->next=nullptr; head=next_node; if(rem>0) rem--; i++; } return result; } };
@rajkrishanmahajan2373
@rajkrishanmahajan2373 Жыл бұрын
my solution class Solution { public: vector splitListToParts(ListNode* head, int k) { ListNode* curr = head; int n = 0; while (curr) { n++; curr = curr->next; } int part_size = n / k; int remaining = n % k; curr = head; vector ans; for (int i = 0; i < k; i++) { ans.push_back(curr); int current_part_size = part_size + (i < remaining ? 1 : 0); for (int j = 0; j < current_part_size - 1; j++) { curr = curr->next; } if (curr) { ListNode* temp = curr->next; curr->next = nullptr; curr = temp; } } return ans; } };
@codestorywithMIK
@codestorywithMIK Жыл бұрын
Awesome ❤️
@tutuimam3381
@tutuimam3381 Жыл бұрын
❤❤❤
@floatingpoint7629
@floatingpoint7629 Жыл бұрын
remainder nodes will never exceed then k thats the reason or this logic works
@yashhhh740
@yashhhh740 Жыл бұрын
hello bhaiya, conceptual clarity ke liye kha se video dekhu? aapke toh video question solution vale hainn naa
@k.vabhavmishra
@k.vabhavmishra Жыл бұрын
bhai Questions ke through bhi seekh sakta h
@aman3210
@aman3210 Жыл бұрын
thankyou bhaiya ++;
@taneyasoni
@taneyasoni Жыл бұрын
6/100
@Letskrakcode
@Letskrakcode 3 ай бұрын
sir approach ajati hai but code karte waqt promblem hota hai or error bhi ata hai please help and guide
@lotusjoshi
@lotusjoshi 9 ай бұрын
** * Definition for singly-linked list. * struct ListNode { * int val; * struct ListNode *next; * }; */ /** * Note: The returned array must be malloced, assume caller calls free(). */ struct ListNode** splitListToParts(struct ListNode* head, int k, int* returnSize) { struct ListNode *current=head; int l=0; while(current!=NULL) { l++; current=current->next; } current=head; struct ListNode* prev=NULL; struct ListNode** result=(struct ListNode**)malloc(k * sizeof(struct ListNode*)); int geteachelement=l/k; int reminderelement=l%k; for(int i=0;inext!=NULL;count++) { prev=current; current=current->next; } if(prev!=NULL) { prev->next=NULL; } prev=NULL; } *returnSize=k; return result; } Getting error in leetcode
@NiveditaKar-xj6ew
@NiveditaKar-xj6ew Жыл бұрын
JAVA SOLUTION : class Solution { public ListNode[] splitListToParts(ListNode head, int k) { ListNode temp=head; ListNode ans[]=new ListNode[k]; int l=0; while(temp!=null) { l++; temp=temp.next; } ListNode curr=head; ListNode prev=null; int part=l/k,rem=l%k; for(int i=0;i0?1:0; for(int j=0;j
@codestorywithMIK
@codestorywithMIK Жыл бұрын
Thank you for sharing Java 😇🙏
@harshit6871
@harshit6871 2 ай бұрын
aj k contest 414 leetcode ki video daal do bhaiya ji🙏
@codestorywithMIK
@codestorywithMIK 2 ай бұрын
Maximum Number of Moves to Kill All Pawns | Step By Step Detailed | Leetcode 3283 | codestorywithMIK kzbin.info/www/bejne/pqvCpJ-Cir5qsJI
@srashtigupta2389
@srashtigupta2389 3 ай бұрын
leetcode pe nhi chlrha ye code please modify krke do
@prudhvirajmacherla9854
@prudhvirajmacherla9854 Жыл бұрын
I didn't understand the last if condition if(prev! =null) prev. Next=null
@prudhvirajmacherla9854
@prudhvirajmacherla9854 Жыл бұрын
Can u explain plz
@lotusjoshi
@lotusjoshi 9 ай бұрын
Can someone can provide the code in c😢😢
@hi-tk4hu
@hi-tk4hu Жыл бұрын
I wrote this. please check it to see if you find it easier to understand and im little confused about time complexity its O(N) ig class Solution { private: int getLen(ListNode* head) { int l = 0; ListNode* ptr = head; while(ptr) { l++; ptr = ptr->next; } return l; } public: vector splitListToParts(ListNode* head, int k) { vector res; int l = getLen(head); int rem = 0, size = 1, cnt = 0; ListNode* prev = NULL; ListNode* ptr = head; ListNode* start = head; cout
@NITianMonika
@NITianMonika Жыл бұрын
I'm getting error Line 36: Char 19: runtime error: member access within null pointer of type 'ListNode' (solution.cpp) SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior prog_joined.cpp:45:19
@NITianMonika
@NITianMonika Жыл бұрын
/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode() : val(0), next(nullptr) {} * ListNode(int x) : val(x), next(nullptr) {} * ListNode(int x, ListNode *next) : val(x), next(next) {} * }; */ class Solution { public: vector splitListToParts(ListNode* head, int k) { ListNode* curr = head; int nodesInList = 0; while(curr){ nodesInList++; curr = curr->next; } int eachBucketNodes = nodesInList/k; int extraNodes = nodesInList%k; vector ans(k, nullptr); // if(head==NULL) return head; curr = head; ListNode* prev = NULL; for(int i=0; inext; } prev->next = NULL; extraNodes--; } return ans; } };
@NITianMonika
@NITianMonika Жыл бұрын
as my writen code is this
@codeandtalk6
@codeandtalk6 Жыл бұрын
❤❤❤
Человек паук уже не тот
00:32
Miracle
Рет қаралды 3,8 МЛН
Osman Kalyoncu Sonu Üzücü Saddest Videos Dream Engine 275 #shorts
00:29
CAN YOU DO THIS ?
00:23
STORROR
Рет қаралды 49 МЛН
У вас там какие таланты ?😂
00:19
Карина Хафизова
Рет қаралды 22 МЛН
Split Linked List in Parts - Leetcode 725 - Python
11:01
NeetCodeIO
Рет қаралды 12 М.
How to Solve ANY LeetCode Problem (Step-by-Step)
12:37
Codebagel
Рет қаралды 288 М.
Lecture 53: Merge Sort in Linked List [ Theory + Implementation ]
27:49
CodeHelp - by Babbar
Рет қаралды 178 М.
Does COLD MAIL & PROJECTs Work?
2:55
Neeraj Walia
Рет қаралды 19 М.
Человек паук уже не тот
00:32
Miracle
Рет қаралды 3,8 МЛН