🔴 2861. Maximum Number of Alloys II Weekly Contest 363 II Binary Search II Leetcode 2861

  Рет қаралды 2,132

Aryan Mittal

Aryan Mittal

Күн бұрын

Пікірлер: 10
@iamnoob7593
@iamnoob7593 8 ай бұрын
Man , This is brilliant , Thank you.
@VishalKumar-uu3xm
@VishalKumar-uu3xm Жыл бұрын
nice explaination sir ji
@RohitKumar-dy2gc
@RohitKumar-dy2gc Жыл бұрын
now ques seems so simple don't know why i afraid first after seeing it in contest
@Anonymous____________A721
@Anonymous____________A721 Жыл бұрын
🤣
@wasurvivor
@wasurvivor Жыл бұрын
I think the binary search solution fails if we think logically. Let me give you a test case n = 3, k = 3 Composition = [[1,1,10],[2,2,5]] Stock = [0,0,50] Cost = [1,1,1] budget = 20 Binary search solution will return 5 because it will choose 1st machine and will make 5 alloys that will cost around (5*2) = 10 and our stocks array will be [0,0,0] and budget will become (20-10) = 10. Still using this 10 we can make one alloy using another machine (5+2+2). Please rectify me if I am wrong.
@saujanyasolanki4242
@saujanyasolanki4242 Жыл бұрын
If you read the description carefully you will see there is a highlighted line in question that tells 'All alloys must be created with same machine' so we cannot use the remaining budget on another machine
@ishankrajpal8231
@ishankrajpal8231 Жыл бұрын
tech wiser huh
@DreamFist
@DreamFist Жыл бұрын
ans=max(ans,res) in maxNumberOfAlloys is not needed ,as we are always incrementing l whenever we find a satisfying budget hence always increasing nature.Please correct me if i am wrong.
@anubhavnegi4230
@anubhavnegi4230 Жыл бұрын
nope res might be incrementing for a particular value in composition while we carry out the binary search but it might change for the next value in composition as we might get a lesser value of res the the previous one so ans is required
"Идеальное" преступление
0:39
Кик Брейнс
Рет қаралды 1,4 МЛН
-5+3은 뭔가요? 📚 #shorts
0:19
5 분 Tricks
Рет қаралды 13 МЛН
Making an Algorithm Faster
30:08
NeetCodeIO
Рет қаралды 192 М.
one year of studying (it was a mistake)
12:51
Jeffrey Codes
Рет қаралды 85 М.
70% of Programmers can't solve this LeetCode Easy Question
7:32
How I Mastered Data Structures and Algorithms in 8 Weeks
15:46
Aman Manazir
Рет қаралды 153 М.
Mastering Dynamic Programming - How to solve any interview problem (Part 1)
19:41
Pass the Pillow || Maths & Logic || Leetcode-2582
10:17
Aryan Mittal
Рет қаралды 4,3 М.
15 Years of Software Engineer Knowledge in 1 hour 30 mins
1:30:39
Rahul Pandey
Рет қаралды 111 М.