Total Cost to Hire K Workers II Greedy II Min Heap II Priority Queue II 2 Pointers II Leetcode 2462

Поділитися
Вставка
  • Опубліковано 20 гру 2024

КОМЕНТАРІ • 13

  • @ARYANMITTAL
    @ARYANMITTAL  Рік тому +4

    Checkout DSA-169 Series: ua-cam.com/video/5BuKVS-Vnws/v-deo.html
    Problem Link: leetcode.com/problems/total-cost-to-hire-k-workers/description/
    Code & Notes: drive.google.com/file/d/14mJ9Kvr-5EkAX2thm1A0IgrQDqK5YG_q/view?usp=sharing

  • @mukulkhanna26
    @mukulkhanna26 Рік тому

    bohot gajab bhai u r my real guru

  • @anexocelisia9377
    @anexocelisia9377 Рік тому +4

    🔥

  • @yashmodi3388
    @yashmodi3388 Рік тому +1

    Can any one help me where i am doing wrong?
    Here is code
    class Solution:
    def totalCost(self, costs: List[int], k: int, candidates: int) -> int:
    cr = 0
    for i in range(k):
    if 2*candidates < len(costs):
    min1 = min(costs[:candidates])
    min2 = min(costs[-candidates:])
    print(min1,min2)
    mi = min(min1,min2)
    cr+=mi
    costs.remove(mi)
    else:
    mi= min(costs)
    cr+=mi
    costs.remove(mi)
    print(mi,costs)
    return cr
    Test Case Passed(108/165)
    Failed one
    costs =
    [50,80,34,9,86,20,67,94,65,82,40,79,74,92,84,37,19,16,85,20,79,25,89,55,67,84,3,79,38,16,44,2,54,58]
    k =
    7
    candidates =
    12
    My answer 86
    Expected 95

  • @karanjitrandhawa1515
    @karanjitrandhawa1515 Рік тому

    Best Explaination

  • @Yogesh-ei1lg
    @Yogesh-ei1lg Рік тому +1

    brother, please explain all langauges codes, will be very helpful including java. Takes hardly 1-2 minute more

    • @Yogesh-ei1lg
      @Yogesh-ei1lg Рік тому

      Don't care for those who cry that the videos are very long. Most of them copies your code without even watching the video doesn't matter its small or big length.

    • @bharathkumar5870
      @bharathkumar5870 Рік тому

      if you are dsa skills are dependent on language..then dsa is not for you bro...learn the language which you aree using first

    • @Yogesh-ei1lg
      @Yogesh-ei1lg Рік тому +1

      @@bharathkumar5870 Looks loke you smoke weed on monday night.. First you are saying that dsa is not for me due to languange dependency & then you are saying learn the language. And, also tell me the weed you are using, seems fantastic!

    • @bharathkumar5870
      @bharathkumar5870 Рік тому +3

      @@Yogesh-ei1lg it u are still asking the mentor to teach the logic in the language you know..then your are unfit for learning

  • @shubhamraj25
    @shubhamraj25 Рік тому +6

    Bhai hil kam aur bol jyada