Minimum Lights To Activate

  Рет қаралды 18,987

Code with Alisha

Code with Alisha

Күн бұрын

Пікірлер: 54
@hey.............
@hey............. 3 жыл бұрын
public class Solution { public int solve(int[] A, int B) { int n = A.length; int i = 0; int count = 0; while(i < n) { boolean isBulbLighted = false; int lr = Math.max(i - B + 1, 0); int rr = Math.min(i + B - 1, n - 1); // 0, 0, 1, 0, 1, 0, 0, 1 for(int j = rr; j >= lr; j--) { if(A[j] == 1) { count++; i = j; i += B; isBulbLighted = true; break; } } if(!isBulbLighted) { return -1; } } return count; } }
@niharikathakur4925
@niharikathakur4925 2 жыл бұрын
Bro, at first I was reluctant to watch a 19 minute video but the way you deliver the solution is absolute delight. The flow of the code and the explanation were in sync.
@JagdeepSingh-cd4jk
@JagdeepSingh-cd4jk 3 жыл бұрын
though the video was bit long , but it was worth watching it!! so nicely explained every bit of the line of code
@bhaveshkumar6842
@bhaveshkumar6842 3 жыл бұрын
This is the best explanation for this question. Great job!
@mrinalmadhav8119
@mrinalmadhav8119 3 жыл бұрын
Mam plz aap continue rakhiye ye series, views ko dhyan mat dijiye Aapke channel bhut precious h Heere ho har koi tarash nhi sakta
@ferozahmadqureshi8071
@ferozahmadqureshi8071 3 жыл бұрын
everytime I am stuck, you come up like magic. Thanks ma'm.
@shimlamam6066
@shimlamam6066 2 жыл бұрын
R u wall clock alwys stuck after putting battary u charged
@nehanjalimanchikanti3974
@nehanjalimanchikanti3974 Жыл бұрын
Most underrated channel
@rohankumarshah5679
@rohankumarshah5679 3 жыл бұрын
quality of Explanation justifies your hard work !!
@IIOT_B1_052_Sachit_Gupta
@IIOT_B1_052_Sachit_Gupta 6 ай бұрын
int Solution::solve(vector &A, int B) { int count =0; int i=0; int n=A.size(); while(i=left){ if(A[right]==1){ found=true; break; } right--; } if(found==false){ return -1; } count++; i=right+B; } return count; } Correct code . i made a small correction i=right +B not right+B-1 as mentioned in the video.
@tanzeelahmed2055
@tanzeelahmed2055 3 жыл бұрын
What an awesome explanation!
@shimlamam6066
@shimlamam6066 2 жыл бұрын
Wow an awesome comment
@ANANDJULU
@ANANDJULU 3 жыл бұрын
Very nicely explained, thank you!
@surajsingh-sm7qx
@surajsingh-sm7qx Жыл бұрын
Nice explaination 😊
@keya.bitspilani5429
@keya.bitspilani5429 Жыл бұрын
Intuitive solution❤
@rudragaming5281
@rudragaming5281 3 жыл бұрын
MOST AWSOME CONTENT MAAM...
@aditikatiyar5933
@aditikatiyar5933 2 жыл бұрын
solving this question looks a piece of cake when explained by her!!!
@anikethdeshpande8336
@anikethdeshpande8336 2 жыл бұрын
nicely explained. !
@sanyamjain7058
@sanyamjain7058 2 жыл бұрын
is Time complexity is O(n^2) ?
@chiragkarnwal6740
@chiragkarnwal6740 Жыл бұрын
Great Explanation❤
@ajaywadhwa3398
@ajaywadhwa3398 2 жыл бұрын
Wow !!!!! Really a good explanations.
@dheerajkumarmeena629
@dheerajkumarmeena629 2 жыл бұрын
Nicely explained. Very easy to understand
@payalpanjwani5332
@payalpanjwani5332 2 жыл бұрын
Good explanation! Thanks for helping out 🤗
@VaibhavSingh-vy6gy
@VaibhavSingh-vy6gy 2 жыл бұрын
Very nicely explained...Thanks
@dhruvpurwar6642
@dhruvpurwar6642 2 жыл бұрын
Fantastic explanation!! KUDOS
@forlaliga7123
@forlaliga7123 3 жыл бұрын
Great explanation
@ramaniruth6792
@ramaniruth6792 2 жыл бұрын
Nicely explained
@masternik6126
@masternik6126 3 жыл бұрын
int Solution::solve(vector &A, int B) { int n = A.size(); int count = 0; int i = 0; bool bulbfound = false; while(i=l){ if(A[r]==1){ count++; i = B+r; bulbfound = true; break; } r--; } if(!bulbfound) return -1; bulbfound = false; } return count; }
@swatishambhavi3649
@swatishambhavi3649 3 жыл бұрын
Great explanation, thanks so much!
@raj_kundalia
@raj_kundalia 2 жыл бұрын
Thanks for the video!
@mdshoiebiqbal6155
@mdshoiebiqbal6155 3 жыл бұрын
Thank you ,that was nice application
@snake_case07
@snake_case07 3 жыл бұрын
Thanks for the explanation 😊
@devanshsharma2106
@devanshsharma2106 2 жыл бұрын
such a good video
@manup7636
@manup7636 3 жыл бұрын
very good explanation the tabs show how much u research for one question🙂
@jatinbhatoya8420
@jatinbhatoya8420 2 жыл бұрын
for java folks: public static int solve(int[] arr, int k) { if (k==0) return -1; int i = 0, count = 0; while (i < arr.length) { int idx = lightItUp(arr, k, i); if (idx == -1) return -1; else { i = idx + k; count++; } } return count; } public static int lightItUp(int arr[], int k, int i) { int j = Math.min(i + k - 1, arr.length - 1); while (j >= Math.max(i - k + 1, 0)) { if (arr[j] == 1) { return j; } j--; } return -1; }
@anujjain9273
@anujjain9273 3 жыл бұрын
i was just doing the mistake in the second while loop , btw nice explanation , but in the starting your voice was little crumbling , and have you made a git hub repo for interviewbit questions?
@meme_engineering4521
@meme_engineering4521 2 жыл бұрын
best explanation!!
@probabilitycodingisfunis1
@probabilitycodingisfunis1 2 жыл бұрын
Glad you liked it
@Your_Boy_Suraj
@Your_Boy_Suraj Жыл бұрын
Python Solution: class Solution: # @param A : list of integers # @param B : integer # @return an integer def solve(self, A, B): count = 0 i = 0 n = len(A) while(i < n): right = min(n-1, i + B - 1) left = max(i - B + 1, 0) bulbFound = False while(right >= left): if A[right] == 1: bulbFound = True break right -= 1 if bulbFound == False: return -1 else: count += 1 i = right + B return count
@dilipparmar3175
@dilipparmar3175 2 жыл бұрын
Can you please upload your code also? It will help us with revision purposes.
@aniketsinghvats767
@aniketsinghvats767 2 жыл бұрын
Wow thanks for the solution. It was an easy question how can't I do that. ;_;
@avtardeepsingh6715
@avtardeepsingh6715 2 жыл бұрын
super..
@shilpapatil1963
@shilpapatil1963 2 жыл бұрын
@dhananjoydey1337
@dhananjoydey1337 2 жыл бұрын
can you please upload solution of Leetcode problem "127. Word Ladder"?
@shimlamam6066
@shimlamam6066 2 жыл бұрын
Surèeeeeeeeeeee dhanajoy i m redy for u
@MayankKumar-nn6us
@MayankKumar-nn6us 2 жыл бұрын
can anyone tell me what will be the time complexity? Is it O(n^2)?
@vedantupadhyay42
@vedantupadhyay42 Жыл бұрын
O(N). The worst case : - A = [0, 0, 0, 0], B = 1 We would have to iterate over every element..
@akshayrathod7679
@akshayrathod7679 3 жыл бұрын
How much avg time did you take to solve questions?
@shimlamam6066
@shimlamam6066 2 жыл бұрын
How much u r taking less than that
@masseffect0128
@masseffect0128 2 жыл бұрын
Idiots setting the corridor from starting index 1, while the array of lights starts from 0. here is the one pass for starting index 0; int i, end = -1, cnt = 0; for (i = 0; i < A.size();) { if (A[i] == 1) { if (i - B + 1 > end + 1) return -1; end = i + B - 1; i += i + B; ++cnt; } else ++i; } return cnt;
@Lifeisgood108-33
@Lifeisgood108-33 2 жыл бұрын
Make a tutorial on how to be focussed to see the main screen while watching your lectures.
@ayushnath3768
@ayushnath3768 2 жыл бұрын
Keep a mirror to the side where you can see your own reflection.
@RehanShaikh-sz4mh
@RehanShaikh-sz4mh 3 жыл бұрын
thank you so much ma'am , I was not getting the problem I was afraid when I have read this problem need DP and backtracking concept and I have not yet studied it thank you so much for the confidante by your explanation I have got the problem
Gas Station or Circular Tour problem
21:38
Code with Alisha
Рет қаралды 14 М.
Quilt Challenge, No Skills, Just Luck#Funnyfamily #Partygames #Funny
00:32
Family Games Media
Рет қаралды 55 МЛН
Мен атып көрмегенмін ! | Qalam | 5 серия
25:41
Quando eu quero Sushi (sem desperdiçar) 🍣
00:26
Los Wagners
Рет қаралды 15 МЛН
Writing Code That Runs FAST on a GPU
15:32
Low Level
Рет қаралды 577 М.
Tell Me About Yourself | Best Answer (from former CEO)
5:15
The Companies Expert
Рет қаралды 7 МЛН
The Absolute Best Intro to Monads For Software Engineers
15:12
Studying With Alex
Рет қаралды 680 М.
Animation vs. Math
14:03
Alan Becker
Рет қаралды 79 МЛН
"Sell Me This Pen” - Best 2 Answers (Part 1)
4:51
Amro_Dubai
Рет қаралды 9 МЛН
FASTEST Way to Learn Coding and ACTUALLY Get a Job
11:49
Namanh Kapur
Рет қаралды 1,5 МЛН
5 Secrets to Stop Stuttering & Speak More Clearly!
12:44
Vinh Giang
Рет қаралды 98 М.
Fast Inverse Square Root - A Quake III Algorithm
20:08
Nemean
Рет қаралды 5 МЛН
Quilt Challenge, No Skills, Just Luck#Funnyfamily #Partygames #Funny
00:32
Family Games Media
Рет қаралды 55 МЛН