BS-2. Implement Lower Bound and Upper Bound | Search Insert Position | Floor and Ceil

preview_player
Показать описание

Notes/C++/Java/Python codes:

We have solved the problem, and we have gone from brute force and ended with the most optimal solution. Every approach's code has been written in the video itself. Also, we have covered the algorithm with intuition.

You can follow me across social media, all my handles are below:

0:00 Lower Bound Explanation using examples
10:53 Lower Bound Implementation
13:35 Lower Bound Code (in C++)
13:55 lower_bound() C++ STL method
15:33 Time Complexity Analysis of Lower Bound
15:46 Upper Bound Explanation using examples
17:23 Upper Bound Implementation
18:56 Upper Bound Code (in C++)
19:13 Time Complexity of Upper Bound
19:20 upper_bound() C++ STL method
19:47 Search Insert Position
22:53 Floor and Ceil in Sorted Array
28:44 How is Binary Search making sure that we get the smallest index?
31:40 Outro
Рекомендации по теме
Комментарии
Автор

Please comment understood and give us a like if you got everything :)

takeUforward
Автор

#Free Education For All.. # Bhishma Pitamah of DSA...You could have earned in lacs by putting it as paid couses on udamey or any other elaerning portals, but you decided to make it free...it requires a greate sacrifice and a feeling of giving back to community, there might be very few peope in world who does this...."विद्या का दान ही सर्वोत्तम दान होता है" Hats Off to you man, Salute from 10+ yrs exp guy from BLR, India.

shubhamagarwal
Автор

I was fearing from binary search but once Understood in depth, I was able to do all question in this lecture my self .
Thank you so much for this wonderful explanation .Just keep doing it .

shashikumar
Автор

27:00 a litlle error please correct if(a[mid]<=x) hoga rather if(a[mid]<=mid)

saketjaiswalSJ
Автор

Floor and Ceil without using "ans" variable -
> For floor just do a normal binary search and return end
> For ceil just do a normal binary search and return start

shaurya
Автор

I am actually revising my concept and this Binary search series has been helpful.
Thanks Striver

habeeblaimusa
Автор

i am on the verge of completing this a2z sheet, hopefully i will do it by the end of june by myself on my own pace since the tougher side of the sheet is already been done by me... u r gem of a person Raj bhya..♥

abhishekverma
Автор

0:00 Lower Bound Explanation using examples
10:53 Lower Bound Implementation
13:35 Lower Bound Code (in C++)
13:55 lower_bound() C++ STL method
15:33 Time Complexity Analysis of Lower Bound
15:46 Upper Bound Explanation using examples
17:23 Upper Bound Implementation
18:56 Upper Bound Code (in C++)
19:13 Time Complexity of Upper Bound
19:20 upper_bound() C++ STL method
19:47 Search Insert Position
22:53 Floor and Ceil in Sorted Array
28:44 How is Binary Search making sure that we get the smallest index?
31:40 Outro

anuragsingh
Автор

thanks for all raj i can see my improvement in problem solving i can't express my feeling

sanjayv-efey
Автор

Understood everything.... Feels like you will taking me forward from my Village to google or Microsoft or Amazon fore sure ❤❤

DTALKS
Автор

Completed graph and dp series in the previous 20 days, and I am super excited to complete this BS playlist as well.

sauravchandra
Автор

Really great series. Made in such a way easy to understand in no time. Great work 👏

mianawais
Автор

I don't usually comment on youtube, but I had to login just to say how incredible was this lesson! Thanks very much for this videos!

thenriquevicentini
Автор

i feel the lower bound explanation and the provided GFG questions don't match with each other, question might be modified after some time

sagarhiremath
Автор

Thank you Striver, My Intuition is actually improving. Its not about solving the problems, its about understanding the diverse approach.

Understood ❤

senseiAree
Автор

Understood! Super amazing explanation as always, thank you very very much for your effort!!

cinime
Автор

Was able to do every single question after lower bound by my self thanks ❤❤. Literally built my thinking ability.

graviton
Автор

In java there is no direct method to find lower bound or upper bound but indirectly you can find with the help of Arrays.binarySearch(arr, target) method


public class Solution {
public static int lowerBound(int []arr, int n, int x) {
// Write your code here
int ans = Arrays.binarySearch(arr, x); // built in method for binary search it will return the smallest index where target is present i.e lower bound else it will return a negative value
if(ans<0){
// To calculate lower Bound
ans = Math.abs(ans) - 1;
}
return ans;
}
}

Thanks

nitesh
Автор

was able to solve both problems as soon as you taught the lowerbound approach.

vishious
Автор

your understanding about Dsa is excellent

rahulkumarsingh