Please watch our new video on the same topic: • BS-24. Search in a 2D ... Check our Website: Notes: • BS-24. Search in a 2D ...
Пікірлер: 99
@takeUforward11 ай бұрын
Please watch our new video on the same topic: kzbin.info/www/bejne/gIm4ZXShm9lqr80
@AbhishekSharma-ip4df11 ай бұрын
bhaiya..kya approach..kya intuition..kya energy..explain krne ka tareeka..legit sb awsm hota h aapka..u make us feel dsa🔥🔥
@prachigoyal2510 Жыл бұрын
A huge thanks Striver for putting all these efforts 🙏
@princebhanushali62552 ай бұрын
Best DSA questions and approaches among all the DSA tutorials on KZbin. Big thankss❤❤
@devkirandass7930 Жыл бұрын
Striver is the best...Feel like worshipping him🥰
@SandeepM0ttan10 ай бұрын
Try kunal kushwaha then
@devkirandass793010 ай бұрын
@@SandeepM0ttanyeah I know him....idk but I felt like he is too arrogant ....and he teaches JAVA and I am into C++
@cinime11 ай бұрын
Understood! Super wonderful explanation as always, thank you very very much!!
@sairam335111 ай бұрын
You are excellent teacher bro,no professor comes close, 💖
@poonam-kamboj10 ай бұрын
very nice and clearly explained , thanks for the good explanation!!
@jhanavikumari2743 ай бұрын
you are definitely doing some sorcery out there like how can you make learning this interesting .
@hardikpatel3523 ай бұрын
Understood! Such a great explanation as always, thank you very much for your effort!!
@Gagansharma30026 ай бұрын
Bhai babbar ke to bus hype h asli udham to tumne machai h student ke learning me❤
@aswinsrikanth40810 ай бұрын
A great explanation as a whole bruh
@harshhwardhanrai3716Ай бұрын
at 10:15 I literally started searching for the intuition for it but thanks for explaining it :)
@theyashsawarkar10 ай бұрын
very very helpfull explaination
@hareshnayak73024 ай бұрын
Understood,thanks striver for this amazing video.
@md.imrankhan691211 ай бұрын
Thank You Mr Legend
@rushidesai28362 ай бұрын
Amazing solution
@mrminus8590Ай бұрын
Thanks for everything brother
@ayushagarwal5271Ай бұрын
coded it down myself! thanks!!
@ashishpradhan62502 ай бұрын
amazing..thanku
@iampatelajeet11 ай бұрын
Thanks Bhaiya 💯❤
@iceyyeah6 ай бұрын
You go crazy love that dude
@NazeerBashaShaik3 ай бұрын
Understood, thank you.
@ArpanChakraborty-do6yz5 ай бұрын
done and dusted❤🔥❤🔥just awesome
@shawshak21489 ай бұрын
understood thanks
@user-tk2vg5jt3l5 ай бұрын
Thank you Bhaiya
@YourCodeVerse7 ай бұрын
Understood✅🔥🔥
@EC20022ELAKKIYAC2 ай бұрын
Understood thank you
@harshitpatil61389 ай бұрын
Understoood✌✌👍👍
@ankanmalik409 Жыл бұрын
dada make a video on - Divide two integers without using multiplication, division and mod operator
@chiragsharma89059 ай бұрын
My code with slightly more intuitive approach(according to me). O(log(n)+log(m)). Finding correct row first, and then finding target in that row. class Solution { public boolean searchMatrix(int[][] mat, int target) { int m = mat.length; if(m==0) return false; int lo = 0; int hi = m-1; while(lo
@saswatrath46463 ай бұрын
great bhai same as my approach
@srujangajjala2658Ай бұрын
log n + log m = log nm so time complexity is still same
@RajNamdev_19Ай бұрын
@@srujangajjala2658 thanks for reminding me log formula I just forgot about it
@arihantjammar888811 ай бұрын
understood
@culeforever54089 ай бұрын
understood 😇
@KartikeyTT12 күн бұрын
tysm sir
@senseiAree9 ай бұрын
Understood ❤
@yatintripathi563811 ай бұрын
Hey Striver , I somehow find this question and Median in a row-wise sorted Matrix a bit similar , but my approach gets wrong when i try to flatten the matrix to find the median. Is my approach wrong towards the question?
@PrabhaKaran-363 ай бұрын
Understood❤
@RituSingh-ne1mk7 ай бұрын
Understood!
@nikhilkumarjamwal53228 ай бұрын
It can also be done in O(n).
@Ajeetkumar-uo4hf8 ай бұрын
Striver Energy OP !!
@artifice_abhi6 ай бұрын
but its not necessary that if my target lies within the range it will surely be there for eg if an array is: 3 6 7 8 and target is 5 so now I would apply binary search as it is within my range but actually its not present. And this can happen for the rows where every time target is within the range but not present there. So in worst case time complexity would be: N*log(M)
@harshilpatel32055 ай бұрын
No brother time complexity in the worst case stays as 0(n) + 0(log2(m)) ... Because once we find the answer we are returning the answer so it'll never go through each row...
@ShahNawaz-cx3piАй бұрын
One more solution can be , first try to find out the correct row from 0th column (element in 0th column
@kundann_n998910 күн бұрын
Can we not do a binary srach on i to look for the row that contains the target the do binary search on that row to look for target?
@suryasaimaheswar86365 күн бұрын
understood :)
@abhishekprasad0103 ай бұрын
Understood
@sarangkumarsingh79012 ай бұрын
Understood...............
@harikakesharaju879911 ай бұрын
Same code u submitted is giving me TLE error for me sir
@manikantachegu218216 күн бұрын
How about finding the row in which the element will be (by binary search ) and then applying binary search on the row can result in logn + logm crct me if im wrong because it worked for me in coding ninjas
@aradhyapandey14898 ай бұрын
bhaiya...kitna bhayankar padhate ho🙏
@graviton0013 күн бұрын
Solved myself ❤
@piyushmahale9024Ай бұрын
❤❤❤❤
@lakshmanprabhu672210 ай бұрын
Which is lesser time complexity, log(m) + log(n) , or log(m*n) ?
@rohitsai80610 ай бұрын
both are same... log a + log b = log ab
@dayashankarlakhotia494311 ай бұрын
Optimal approach. Public class solution { static boolean Search in matrix( Array list mat,int target){ int m=mat.size(),n=mat.get(0).size (); int low=0, high =m*n -1; while (low
@sayantanpoddar54285 ай бұрын
Understood.............Understood!!!!! G.O.A.T
@shashankgsharma0901Ай бұрын
Understood, but please take m x n instead of n x m, took i / m the whole time taking m x n, so got segmentation fault the entire time.
@studyah3 ай бұрын
bhaiya why did you take log of base 2?
@saswatrath46463 ай бұрын
search space is reducing by half everytime we are doing mid = (low +high)/2. Anytime if you are reducing your working space by diving something your time complexity becomes log base to diviser. Had we been doing mid = (low + high)/5, just imagine it, our time complexity would have been log base 5. Hope it helps!
@studyah3 ай бұрын
@@saswatrath4646 thanks for explaining:) But I can't grasp why it happens...why the time complexity becomes log of base of the divisor
@saswatrath46463 ай бұрын
@@studyah Search space is reducing from N to N/2 to N/4 to N/8 and so on.. why so ? bcz we are doing eliminating one half either left of right from the mid according to our situation. before you read any further 2^k means 2 raised to the power k. Here is the detailed explanation buddy. You can also write N, N/2, N/4, N/8..... as N/2^0 , N/2^1, N/2^2, N/2^3.....let's say it goes till 2/2^K. N/2^K = 1 hoga right ? kyuki last me 1 element == target hoga. Solve the equation, N = 2^k hog. Recall the formula of log and exponential or search it on google, if N = 2 ^ K then K = log base 2 of N. Now if you observer we are going from 1 to K right ? when we were at 1 we considered the whole array, when we were at k we comsidered only a single element. So, we moved from 1, 2, 3,...K. K number of iterations, now what is K that we found out above ? log base 2 of N. Time complexity will be O(k) =O(log base 2 of N) .
@CodingJoySoul Жыл бұрын
Please help Indians become candidate masters on codeforces.
@rahulhembram451911 ай бұрын
UnderStood
@aniketdas43586 ай бұрын
why am i getting runtime error with this code bool find(vector &arr,int col,int target) { int lo=0; int hi=col-1; while(lotarget) { hi=mid-1; } else if(arr[mid]
@saswatrath46463 ай бұрын
when u r asking out do mention type or name of the error, it wil assist the person trying to help u out.
@saswatrath46463 ай бұрын
change col to mat[i].size() and row to mat.size(), and write the col inside the for loop before calling bool function it will work perfectly fine.
@nakulchauhan67136 ай бұрын
Your content and amount of effort is great. Huge respect for this course and you. But i feel you are not poking students to think, it appears as if you already know answer and here you are explaining it. Thought to process to come to a point should also be recorded. Lets say live solving DSA problems.
@Fe-ironman6 ай бұрын
You should watch this video only after going through the problems yourself
@dayashankarlakhotia494311 ай бұрын
BF approach. Public class { static boolean search matrix (Array list mat,int target){ int m=mat.size(), n=mat.get(0).size (); for(int i=0;i
@cenacr00710 ай бұрын
us
@pulamollavenkatreddy816211 ай бұрын
Can we do this O( log(n)+ log(m)) by eliminating rows
@abhisheknag192911 ай бұрын
yes
@rohitsai80610 ай бұрын
log(m) + log(n) = log(m*n) as per logarithms.. So both time complexities are same