Leetcode 2141 Maximum Running Time of N Computers

  Рет қаралды 1,624

Jeevan Kumar

Jeevan Kumar

Күн бұрын

Пікірлер
@DevanshAgarwal-tf7jt
@DevanshAgarwal-tf7jt Жыл бұрын
You can avoid doing +1 for mid by doing this as everytime your ans will become 1 less than low:- bool check(long long time, long long n, vector batteries) { long long sum = 0; for (long long i : batteries) { sum += min(time, i); } return (sum >= (long long)time*n); } long long maxRunTime(int n, vector& batteries) { long long sum = 0; for (int i = 0; i < batteries.size(); i++) { sum += batteries[i]; } long long low = 1; long long high = sum / n; long long mid; while (low
@JeevanKumar-code
@JeevanKumar-code Жыл бұрын
Upcoming Workshop on LinkedList: us06web.zoom.us/meeting/register/tZErf-ioqT0uGNPQbn4BMqWTx9s6EoOW7fcZ
@jr_jeet
@jr_jeet Жыл бұрын
Nice sir
@JeevanKumar-code
@JeevanKumar-code Жыл бұрын
Thank you!
@leepakshiyadav1643
@leepakshiyadav1643 Жыл бұрын
amazing, explanation :)
@JeevanKumar-code
@JeevanKumar-code Жыл бұрын
Thank you!
@ritikagrover2724
@ritikagrover2724 Жыл бұрын
class Solution { public boolean check(int n, int []B,long time){ long sum=0; for(int i:B){ sum+=Math.min(i,time); } return (sum>=time*n); } public long maxRunTime(int n, int[] batteries) { long sumPow=0; for(int i:batteries) sumPow+=i; long left=1, right=sumPow/n; while(left
@saudphysics5206
@saudphysics5206 Жыл бұрын
what is pool and why it is used?
@prasidmitra6859
@prasidmitra6859 Жыл бұрын
The first approach is O(mlogm) m = no of batteries and the binary search approach is O(mlogk). It's given that k >> m. It seems that the frist one is better. Why use binary search?
@devverma3168
@devverma3168 Жыл бұрын
why are we doing +1 for calculating mid
@JeevanKumar-code
@JeevanKumar-code Жыл бұрын
Hey, since we are returning left as the ans and updating l = mid. Say l = 5 and r = 6 mid = 5 and leads to infinite loop
@geetdeveloper
@geetdeveloper Жыл бұрын
if you do not add 1, it will always pick left mid in even length or array, but here we want to pick and try check for right mid element of array, therefore added +1
LeetCode 1870 Minimum Speed to Arrive on Time
10:55
Jeevan Kumar
Рет қаралды 1,5 М.
I thought one thing and the truth is something else 😂
00:34
عائلة ابو رعد Abo Raad family
Рет қаралды 9 МЛН
How to Fight a Gross Man 😡
00:19
Alan Chikin Chow
Рет қаралды 17 МЛН
Don't underestimate anyone
00:47
奇軒Tricking
Рет қаралды 21 МЛН
Thank you Santa
00:13
Nadir Show
Рет қаралды 36 МЛН
Leetcode  2742  Painting the Walls
18:45
Jeevan Kumar
Рет қаралды 1,3 М.
LeetCode 2448 Minimum Cost to Make Array Equal
8:17
Jeevan Kumar
Рет қаралды 1 М.
Leetcode 475. Heaters [Java] P.S. Explanation with nice pictures
11:26
if else statement
Рет қаралды 2,6 М.
Animation vs. Math
14:03
Alan Becker
Рет қаралды 75 МЛН
Leetcode 2050 Parallel Courses III
14:21
Jeevan Kumar
Рет қаралды 824
Machine Learning for Everybody - Full Course
3:53:53
freeCodeCamp.org
Рет қаралды 8 МЛН
⚡️NEWS | RUBLE COLLAPSE | STRIKE ON CRIMEA | PUTIN IN KAZAKHSTAN
10:34
Ходорковский LIVE
Рет қаралды 192 М.
I solved 541 Leetcode problems. But you need only 150.
7:42
Sahil & Sarra
Рет қаралды 2,4 МЛН
I thought one thing and the truth is something else 😂
00:34
عائلة ابو رعد Abo Raad family
Рет қаралды 9 МЛН