MAXIMUM PERFORMANCE OF A TEAM (Leetcode) - Code & Whiteboard

แชร์
ฝัง
  • เผยแพร่เมื่อ 4 ม.ค. 2025

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

  • @mikaylaamberremax9633
    @mikaylaamberremax9633 3 ปีที่แล้ว +1

    Great video, can you do an explanation on strobogrammatic number lll?

  • @sensen338
    @sensen338 3 ปีที่แล้ว +1

    Great explanation :) expecting video for Minimum Difficulty of a Job Schedule

  • @KiyotakaAyanokoji1
    @KiyotakaAyanokoji1 ปีที่แล้ว

    it really gave clarity through that dry run!! , i think i mis-read the question though , . . . . .what i thought was -> , it was necessary that we have exgatly k employees selected ? our(your) code can give (maximum )answer even when we dont consider k people , but less than k people , , here is a test case . . . . eff = [100 , 1 , 1] , speed = [100 , 1 , 1 ] k = 3 , so we need 3 people but taking only the first guy gives us
    the answer as 100*100 , while taking all three of them reduces our answer to 1*(100+1+1)=102 , ,, , this is could be a variant to the original question , small change to our code like start taking maximum only when the size of heap has reached k should just do the thing!! Happy learning !

  • @manmaybarot4768
    @manmaybarot4768 3 ปีที่แล้ว

    thanks

  • @aparajitasengupta5558
    @aparajitasengupta5558 3 ปีที่แล้ว

    Hi Aleks, Thank you for your amazing videos. Could you also consider doing one on Remove Invalid Parentheses :)

    • @babybear-hq9yd
      @babybear-hq9yd  3 ปีที่แล้ว +2

      thanks aparajita! I'll add it to the list -- I know that one's a bit of a bitch to solve

  • @nikhilchandna4851
    @nikhilchandna4851 3 ปีที่แล้ว

    Great Explanation

  • @samuhvarta
    @samuhvarta 3 ปีที่แล้ว

    Awesome! Thank you!!!!

  • @rachadaraussayakhun1781
    @rachadaraussayakhun1781 3 ปีที่แล้ว

    Thanks!

  • @albertjtyeh53
    @albertjtyeh53 3 ปีที่แล้ว

    so why does the logic of sorting the tuples by the max efficiency work, it isnt really explained in the videos. thanks

    • @babybear-hq9yd
      @babybear-hq9yd  3 ปีที่แล้ว +1

      At any given step as we're traversing through that array "a", we know that the absolute best job we could do at that efficiency would be the sum of the prior 1-k total speeds. In my next step, my efficiency will be less than (or equal to) my previous efficiency, meaning that I know for a fact, once again, that my maximum performance would be the current efficiency times the prior 1-k total speeds. We rinse and repeat until completed! Doing the sort allows us to not have to do the brute force approach mentioned near the start of the video -- we pay up on the O(nlogn) cost up front to save from the exponential time operation of finding all combinations of 1-k workers for each efficiency.

  • @almasabdrazak5089
    @almasabdrazak5089 3 ปีที่แล้ว

    You stopped an example on the most confusing part which is pair 3,3
    In this case your heap would have 5,10,3 it's bigger than 2 so you drop the 3 and then in your code you do
    result = max(60,15*3(3 is efficiency=45) which still result 60 , but the thing is you still do a comparison even though 3 was dropped from the heap. Why greedy approach works here even though logically we should skip 45 and move further

    • @babybear-hq9yd
      @babybear-hq9yd  3 ปีที่แล้ว

      Actually 3 is not dropped -- 2 would be dropped from the heap. We're using a MIN heap because we want to keep track of MAX values. I'm not sure I fully understand the question; we're not skipping through anything, as we actually walk through every single efficiency.

    • @almasabdrazak5089
      @almasabdrazak5089 3 ปีที่แล้ว

      @@babybear-hq9yd 2 is the k, head has 5,10 then we add 3, size is bigger than 2 so we drop 3 but still check if 5+10*3 is bigger than 60(previous max value) it's logically incorrect

    • @almasabdrazak5089
      @almasabdrazak5089 3 ปีที่แล้ว

      Just try to finish your example from scratchpad and you would see that logic is incorrect, but it still works , I have no clue how to prove this greedy solution