IPO | Easy Beginner Friendly | Story To Code | Leetcode 502 | codestorywithMIK

แชร์
ฝัง
  • เผยแพร่เมื่อ 27 ต.ค. 2024

ความคิดเห็น • 82

  • @aws_handles
    @aws_handles 4 หลายเดือนก่อน +17

    Those who don’t know,
    Try watching single threaded cpu video by MIK
    This will no longer be Hard
    Bawal teacher ho aap ❤❤❤

  • @manojitsaha6262
    @manojitsaha6262 4 หลายเดือนก่อน +11

    You are the best mentor for DSA bhaiya ❤❤❤❤ aj jitna bhi skilled hua hu DSA me apke liye...😊

  • @Abhay14
    @Abhay14 4 หลายเดือนก่อน +13

    What a great explanation bhaiya 😍

  • @mdshujaullah7072
    @mdshujaullah7072 24 วันที่ผ่านมา +1

    Best solution I have ever seen ❤❤❤❤❤

  • @bhargavinaik8145
    @bhargavinaik8145 4 หลายเดือนก่อน +4

    For people who are asking why not DP? I had the same doubt I even tried to solve it with DP but could not pass all TCs, Got TLE, after going through some of the comments in the question I figured out. why dp is not suitable
    1. The constraint is too high.
    2. The local max will effect the global max so checking all possible choices is not needed.
    3. The w is not reducing after picking any project. So if there was a project that we could have picked previously we will still be able to pick that project after finishing some other project. So we dont have to backtrack and check what would have happened for the next input if I dint do what I did earlier.

  • @moupiya9286
    @moupiya9286 4 หลายเดือนก่อน +3

    I think what you say at the beginning of your video, "medium/hard marked hain magar hum ise kafi easy bana denge ki aap khudse code kar pawoge," has some magical power in it. I've seen this happen many times. Even when I know which approach to use from intuition (and constraints), I just can't figure out how to apply them. After struggling for hours, I finally come to TH-cam to watch your video, and after hearing that, I think, "Okay, let's give it another try." Most of the time, during that attempt, I get some idea of how to apply the technique. After trying for some time, it just works.

  • @masoomyf
    @masoomyf 4 หลายเดือนก่อน +1

    brilliant explanation, so much easy... you did nothing but you did everything... ❤. Why I can't think, maybe because I want to hear a new story from you.

  • @jeehub041
    @jeehub041 4 หลายเดือนก่อน +2

    Sir literally aaj maza aa gaya iska concept samajh ke hum initially jab problem dekha the tab hum isko vector of pair of profit and cost banana ka soche and then usko sort karenge jyada profit ke basis pe and then traverse karke best answer nikal lenge.
    But aapne acha explain kia ki profit se pehle capital toh dekho aap usse bandhe hue ho so pehle is kam capital ke basis pe sort karo vector of pair ko.
    Thanks sir 🎉fot such nice mind blowing explanation.

  • @pokeindia5361
    @pokeindia5361 4 หลายเดือนก่อน +2

    Solved on my own!!.... Thank you for your efforts

  • @akshatsoni3183
    @akshatsoni3183 4 หลายเดือนก่อน +1

    Aapke explanation ke baad khudse code kar liya bhaiya❤❤

  • @harshadakoranne475
    @harshadakoranne475 4 หลายเดือนก่อน +2

    I could solve this question because i saw your single threaded CPU question's explaination. Just some minor changes in that code!!
    Thankyou for teaching in such manner and building up our intution !

    • @aws_handles
      @aws_handles 4 หลายเดือนก่อน +1

      Hey same for me. Single threaded cpu was awesome

  • @Lakshya-f4l
    @Lakshya-f4l 4 หลายเดือนก่อน +1

    Great Explanation!

  • @AbhijeetMuneshwar
    @AbhijeetMuneshwar 4 หลายเดือนก่อน +1

    Respected MIK Sir,
    Thanks for explaining this Hard level problem in so much easy way.

  • @PriyanshuSingh-rm5xg
    @PriyanshuSingh-rm5xg 4 หลายเดือนก่อน +1

    This explanation is awesome 💯
    Hoping to learn a lot from you

  • @brokegod5871
    @brokegod5871 หลายเดือนก่อน

    I think the heap operation in worst case (when all projects have same capital need as the current 'w') would be nlogn + klogn, nlogn for the push and then k times we need to pop and pick.
    Total = nlogn + nlogn + klogn = O(nlogn + klogn)
    If n>>k, O(nlogn)
    If k>>n, O(klogn)

  • @thekindspill
    @thekindspill 4 หลายเดือนก่อน +3

    You are a magician mik.
    I can say now this is indeed a Medium level problem

  • @monikavaid5083
    @monikavaid5083 4 หลายเดือนก่อน

    Very easy to understand! Great explanation 😇

  • @amango6297
    @amango6297 4 หลายเดือนก่อน +2

    thanku bhiya for very good and clean explanation i am also doing this JUN Leetcode Challenge :)

  • @pulkitsharma2304
    @pulkitsharma2304 4 หลายเดือนก่อน +1

    great explanation bhayia

  • @Studykaro-ko8zn
    @Studykaro-ko8zn 4 หลายเดือนก่อน +1

    Best explaination!!

  • @shashankpatil3132
    @shashankpatil3132 4 หลายเดือนก่อน +1

    Great explanation ✨

  • @journey_of_me_vs_me
    @journey_of_me_vs_me 4 หลายเดือนก่อน

    Very Lovely !!!

  • @gui-codes
    @gui-codes 4 หลายเดือนก่อน

    Most underrated channel. Why don't you advertise or post on social media to spread words about your channel.

  • @nikhilrathi3627
    @nikhilrathi3627 4 หลายเดือนก่อน +1

    Sorry bro offer lene ke badd mai tanda pad gaya 3 mahine baad aaj phir se shuru kar raha hu. ashirvad do ke mai consistent rahu. Aur ab next target product based. 🙏

  • @gauravbanerjee2898
    @gauravbanerjee2898 4 หลายเดือนก่อน

    Thanks a lot bhaiya ❤❤

  • @sumitgupta310
    @sumitgupta310 4 หลายเดือนก่อน

    what a great explaination!!

  • @souravjoshi2293
    @souravjoshi2293 4 หลายเดือนก่อน +2

    today's POTD "Most Profit Assigning Work" is a similar problem.

    • @aniketnama8390
      @aniketnama8390 27 วันที่ผ่านมา

      can you please share the code of the following

  • @ugcwithaddi
    @ugcwithaddi 4 หลายเดือนก่อน

    One word - WOW 👌🏻

  • @heenamittal8621
    @heenamittal8621 4 หลายเดือนก่อน

    Hello, Thanks for making this hard problem easy. 👏 Can you pls make a video explaination of Leetcode 768 as well, Good explainations are not available on TH-cam for this question. It would be great if you could take out some time and make a video on it. Thanks ! :)

  • @priyanshkumar17
    @priyanshkumar17 4 หลายเดือนก่อน

    Great Explanation !!

  • @justlc7
    @justlc7 4 หลายเดือนก่อน

    Hey, this is great content, thanks for your efforts!
    I wanted to ask, do you also upsolve contest questions?

  • @pranavpranjal2717
    @pranavpranjal2717 4 หลายเดือนก่อน

    i did upto the sorting part ut was unable to figure out how to use heap in this problem. Thanks for the solution.

  • @ZilaGhaziabad99
    @ZilaGhaziabad99 4 หลายเดือนก่อน +1

    Sir can this problem with dp like by using take skip concept..and return the maximum..

  • @focusman8801
    @focusman8801 4 หลายเดือนก่อน +1

    for Time complexity
    what if k =4 and n = 50 and for all projects capital is 0
    then pq will add all n elements in while loop so in this case can we consider time complexity
    of while loop with k as O(k*n * log n) ?
    please answer

  • @sauravchandra10
    @sauravchandra10 4 หลายเดือนก่อน

    Somehow this question seemed difficult. Was not able to get the intuition on how to solve this one and even after seeing the solution, was not able to code this on my own.

  • @anubhavsharma398
    @anubhavsharma398 22 วันที่ผ่านมา

    thanks bhaiya for these wonderful solutions... Can you help me how your record good audio on ipad as I also want to start recording on my ipad?

  • @11csepratikshaargulewar71
    @11csepratikshaargulewar71 4 หลายเดือนก่อน +1

    can we not sort the vector based on the first element of each inner vector in ascending order. However, when the first elements of two adjacent inner vectors are equal, we can sort them in descending order based on the second element using custom sort

  • @sonakshibajpai6445
    @sonakshibajpai6445 4 หลายเดือนก่อน

    thanks a lot!!

  • @sinnohperson8813
    @sinnohperson8813 4 หลายเดือนก่อน +1

    I tried to combine the vectors in vectors of pairs and then sort it and find it greedily
    23/35
    The test case that was shown wrong had 111 n value. So I can't debug it
    How will you deal with those situations?

  • @thorodinson7259
    @thorodinson7259 4 หลายเดือนก่อน

    you are legend!

  • @redox-7092
    @redox-7092 4 หลายเดือนก่อน

    Hey , Thanks CodeStoryWith Mik ! Can You help me ? Actually mein approach soch leta hoon but code m implement nhi krpata kuch suggestion , Yeh wala question ki approach bhi soch li thi but code nhi ho rha tha.

  • @amirsuhail7126
    @amirsuhail7126 4 หลายเดือนก่อน

    kya priority queue k bina bhi kar skte hein sorting me hi custom comparator use kar k ?

  • @shreyansh8789
    @shreyansh8789 4 หลายเดือนก่อน

    Bhaiya jab ek baar koi profit use kar liya toh dubara use nhi kar sakte hai,but code meh hamne vector se woh element remove hee nhi kiya use karne ke baad, fir bhi code kaise chal raha hai error nhi aa raha??

  • @PratikTripathy-yy4kz
    @PratikTripathy-yy4kz 4 หลายเดือนก่อน +1

    But what will happen, when we have a case where capital[i]>profit[i], according to your solution, that will also be calculated, but that will minimize our total profit?????

    • @jagritbudhiraja6391
      @jagritbudhiraja6391 4 หลายเดือนก่อน

      Haan toh bhai hum priority queue mei store karwa rahe Hai na toh wo apne aap max profit laakar dedega

  • @nkd575
    @nkd575 4 หลายเดือนก่อน

    cant be make min heap acc to capital and using custom comparator , in case of tie , we keep high profit at top

  • @Jestermind
    @Jestermind 4 หลายเดือนก่อน

    Bhaiya C++ me DSA kru ya Java me please bta do bahut zyada confused hu...

  • @floatingpoint7629
    @floatingpoint7629 4 หลายเดือนก่อน

    how to figure out whether the problem should be solved by DP or greedy?

  • @shubhtalk7073
    @shubhtalk7073 4 หลายเดือนก่อน

    Bhai cheery pickup 1 pe video banao please 🥺🥺 not cherry pickup 2

  • @namankumar2220
    @namankumar2220 4 หลายเดือนก่อน

    what if in the question, w is decreased by the capital of the project?

  • @nikeshsingh2081
    @nikeshsingh2081 4 หลายเดือนก่อน

    Make vedio on Leetcode 315

  • @peterfromengland8663
    @peterfromengland8663 4 หลายเดือนก่อน

    solved on my own just came her to other solution

  • @samharsh1261
    @samharsh1261 4 หลายเดือนก่อน +1

    why dp solution does not work apart from constraints being tight?

    • @zebra-er6xc
      @zebra-er6xc 4 หลายเดือนก่อน

      I tried using the inclusion, exclusion principle but since index, number of projects and money there are 3 changing vairables, I think we need to use 3-D dp to implement this

  • @A_Myth963
    @A_Myth963 4 หลายเดือนก่อน

    can we do it with min heap and a comparator function... if yes then someone pls explain how ???

  • @pratik.784
    @pratik.784 4 หลายเดือนก่อน +1

    easiest hard question

  • @shabananoor9423
    @shabananoor9423 4 หลายเดือนก่อน

    ❤❤

  • @jevinkardani
    @jevinkardani 4 หลายเดือนก่อน

    Goa me ek bade se W ke neeche ....

  • @Ronakrewar
    @Ronakrewar 4 หลายเดือนก่อน

    why we are not iterating again from start in while(k--) loop.because all from start are less then w? please answer .

    • @harshadakoranne475
      @harshadakoranne475 4 หลายเดือนก่อน +1

      Because we need k distinct projects

  • @RohitRaj-hl6ji
    @RohitRaj-hl6ji 4 หลายเดือนก่อน

    can someone explain this testcase capital[] = {0,1,2} and profits[] = {1,2,3} w = 0 and k = 10. the output is 27 for this testcase. I am not able to figure out how this case is handled in the code.

    • @gui-codes
      @gui-codes 4 หลายเดือนก่อน

      output 6 hoga bhai.
      k = 10 to hai but we only have 3 projects available and we will be able to do all of them with.
      1 + 2 + 3 = 6

    • @RohitRaj-hl6ji
      @RohitRaj-hl6ji 4 หลายเดือนก่อน

      @@gui-codes yeah Yeh pehele yeh testcase output 27 de rha tha but phir 6 Dene lga tha. Maybe a glitch 🤔

  • @AmandeepSingh-gv8gg
    @AmandeepSingh-gv8gg 4 หลายเดือนก่อน +1

    mik why not 0 1 knapsack intutuin?

    • @RohanPatil-gz6un
      @RohanPatil-gz6un 4 หลายเดือนก่อน

      because of extremely tight memory constarints. it will lead to mle

    • @RohitRaj-hl6ji
      @RohitRaj-hl6ji 4 หลายเดือนก่อน

      because the w is purely increasing here but in knapsack we used to decrease our weight when we used to pick that weight element but here we are not decreasing the value of w. Also the constraints are much higher here.

  • @ayaanrashid960
    @ayaanrashid960 4 หลายเดือนก่อน

    this question is similar to 0/1 Knapsack

  • @jays2144
    @jays2144 4 หลายเดือนก่อน +1

    Hello MIK bhaia.
    How to think greedy vs dp. like here why greedy worked??

  • @11csepratikshaargulewar71
    @11csepratikshaargulewar71 4 หลายเดือนก่อน +1

    correct me if i am wrong but, isn't this question leading to the concept of knapsack 0/1 ?

  • @aizad786iqbal
    @aizad786iqbal 4 หลายเดือนก่อน

    can we use tree set or some other data structure instead on heap/ PQ??

  • @anjleshwasule2214
    @anjleshwasule2214 4 หลายเดือนก่อน +1

    this problem is similar to knapsack / house robber

  • @DevOpskagyaan
    @DevOpskagyaan 4 หลายเดือนก่อน

    Damn 🫡🫡🙌