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
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 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!
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
bohot gajab bhai u r my real guru
🔥
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
exactly same for me
Best Explaination
brother, please explain all langauges codes, will be very helpful including java. Takes hardly 1-2 minute more
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.
if you are dsa skills are dependent on language..then dsa is not for you bro...learn the language which you aree using first
@@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!
@@Yogesh-ei1lg it u are still asking the mentor to teach the logic in the language you know..then your are unfit for learning
Bhai hil kam aur bol jyada
don't watch