1:10:00 Thank you so much Bhaiya //count zero in given array which consists only 1 and 0 int countZeroes(int arr[], int n) { // code here int count=0; for(int i=0;i
I have tried a lot of courses..... But everyone is telling a concept verbally and directly write the code...... Neither they dry run nor they tell how the loop is iterating.... 🥺❤ ..
bhaiya logic banana aur implement karna , vo chotey chotey points ko dimaag mein rakhna ab kaafi default sa lagney laga hai aapki videos dekhkar .... thank you for the efforts bhaiya
@@Jv_Singh37 Because at maximum the number of iteration will go till sqrt(n). Let's say 25, then you start checking from 1, then 2, then 3, then 4, then 5, after that, if you want to go one step ahead i.e more than sqrt(25), then that square will exceed 25.
Ram Ram Rohit bhai series bahut baddiya chal rahi hai aur sab kuch chamak raha hai apki wajah se best DSA corse on the internet thanks for the GOAT content man love&&respect++;
I was stuck on the sqrt(n) problem when you gave that in hw so when I checked the solution people were solving it using binary search but was not able to understand the code then but now I think it will be made crystal clear by you bhaiya . Thankyou bhaiya ❤❤
26:03 Optimization to Find First and Last Position of Element in Sorted Array 🚀🚀 We can check the adjacent left or right element matching or not, and this way we can avoid unnecessary search in left and right subarray. class Solution { public: vector searchRange(vector& nums, int target) { int firstIndex = -1, lastIndex = -1; int start=0, end = nums.size() - 1, mid; while(start
Bhaiya i am in class 9th and your teaching methods are so good that i got to know every topic crystal clear . I am watching your videos from day 1 and i will definitely complete the 180 challenge By Abhay Deep
1:09:54 //Count occurrences class Solution{ public: /* if x is present in arr[] then returns the count of occurrences of x, otherwise returns 0. */ int count(int arr[], int n, int x) { int first = -1,last = -1,mid; int start = 0,end = n-1; while(start
Question - 2 34:00 crux of this problem is " target says:- merse badaa number may be mera position occupy kiya hua h so let me consider that in my answer variable aur merse chhote number se mujhe koi dikkat nhi h"
@@Billy-gd1rm Bhaiya ne bahut achhe se samjhaya h. ek baar aur rewind kar ke dekho... Basically is question me two times binary search lagana h one for first and one for last... do these steps for both the search : 1. apply binary search and find the target element and consider in the answer. 2. Don't terminate the loop find in left and right for respective reaches. 3. keep finding till while loop end. 4. This will give you leftmost and rightmost index of that element for the respective search this is the code you may refer : //User function template for C++ class Solution{ public: /* if x is present in arr[] then returns the count of occurrences of x, otherwise returns 0. */ int count(int nums[], int n, int target) { // code here
//first occurance
int start=0,end=n-1,mid=0,first_index=-1; while(start
@@Billy-gd1rm explain the error you can refer this code: //User function template for C++ class Solution{ public: /* if x is present in arr[] then returns the count of occurrences of x, otherwise returns 0. */ int count(int nums[], int n, int target) { // code here
//first occurance
int start=0,end=n-1,mid=0,first_index=-1; while(start
Sqrt(n) wala phela code hua jo mai thoda apka logic dekh ke khud se banaya aur khud se samjh gaya ki isme errors aayenge toh usko kaise handle krna h INT MAX ka output kaise print krwana h ❤ Thanx bhaiya apki videos se sirf theory nhi balki bohot logic lagana bhi sikh rha hu padhai me bhi itna logic nhi laga pata 😂😂
bhiya sqrt wale q me jab hum (mid * mid ) karenge to wo int ki upper limit k bhr b to jaa skta h naa PS :- ha aapne cover krdiya wo cheeej baad me sry mene dekha nahi tha
Bhaiya dout support ka kya hua!?? Mene multiple times aa same chiz comment bhi ki different videos pe pr koi reply nhi aata. Mene subscription liya hua hai pr jo links aape provide kiya he bo khulte nhi or aap new link provide krbate nhi mene aase a aspect nhi kiya tha!
In second question of search insert position can we return start after running the whole while loop then by checking the condition if start > end , in case if the element is not found . Then also our problem will be solved
Bhaiya in 2nd Q initially I took index= -1 ...and rest of the code is same but when si=mid+1 , I updated the as index =si; means mid pr to possible nhi h but mid+1 pr to ho skta h na.....so is it a correct approach???
Day 31 of #180DaysOfCode completed In Today's class, the observation is that how much is essential to get the approach first and then code because all the game of approach code written can be done in a few minutes.
K th missing number using linear search . code : #include using namespace std; int main(){ int size , arr[100] , k; cout > size; cout arr[i]; } cout > k; int n=0 , i=1; while(n
MY APPROACH FOR THE SEARCH INSERT POSITION int n=nums.size(); int start=0,end=n-1; int mid; while(starttarget) { end=mid-1; } else { start=mid+1; } } if(nums[mid]>target) return mid; else return mid+1;
my mathematics teacher used to say one thing "apni walil sabko achhi lagti hai" although aapka metjod was easier to understand but apna method sabko best lagta 😂😂❤
saach bolu to aisa content abhi youtube me aya hi ni hai fadu level ka concept koi hau ni takar me apka bhaiya 2 cr package bande ne aise hi ni phod rakha hai
Bhaiya we can easily write the program of square root like this #incude #include Using namespace std; Int main () { Int n; Courtn; Int a=sqrt(n); Court
count zero int countZeroes(vector &arr) { // code here int mid; int start =0; int end =arr.size()-1; int ind; while(start0){ start =mid+1; } else{ ind =mid; end =mid-1; } } return (arr.size())-ind; }
H/W sheet achee se kar lena❤
Ok bhaiya
1:10:00
Thank you so much Bhaiya
//count zero in given array which consists only 1 and 0
int countZeroes(int arr[], int n) {
// code here
int count=0;
for(int i=0;i
ok bhai
Chamka bhaiya
00 q1, 21:14 its code, 26:17 q2 40:47 its code, 42:00 sqrt question 1:00:26 its code 1:07:00 Homework questions
I have tried a lot of courses..... But everyone is telling a concept verbally and directly write the code...... Neither they dry run nor they tell how the loop is iterating.... 🥺❤ ..
These are the basics of C++ , you should have a good command over c++ to learn dsa in c++.
At 1:03:00 , we can initialize "mid" as long long rather than int. This will resolve all errors automatically.
27:33
class Solution {
public:
int searchInsert(vector& nums, int target) {
int start =0,end =nums.size()-1;
int mid;
while(start
36:46 we can directly print "first"
Because first will hold the possible index value of the not found element 👍
00:00= Q1) First & Last position of an element in an Array, 04:25=When to use Linear search & Binary Search, 21:16= Leetcode platform,
bhaiya logic banana aur implement karna , vo chotey chotey points ko dimaag mein rakhna ab kaafi default sa lagney laga hai aapki videos dekhkar .... thank you for the efforts bhaiya
Matlab
Bhai ye default kyo kah rahe h, mere samajh me aa raha h sir jo padhate h, aapka review kya h plz batayiga @@dontreadmybanner2002
2nd question(search insert position) me normal binary search bhi use karr sakte hai bas end me -1 ki jagah start return karna hoga.
Mere leetcode mai kuch nahi return karne se bhi sahi ho raha hai
Thankyou Rohit Bhaiya, you explain every topic very patiently and step by step. Amazing Lecture 🥰
1:03:57 we can also do long mid = start+(end-start)/2
I am facing time limit exceeding issue, what should I do ?
@xavdok check condition of loop
45:50 The time complexity is sqrt(n)
explain how ?
@@Jv_Singh37 Because at maximum the number of iteration will go till sqrt(n). Let's say 25, then you start checking from 1, then 2, then 3, then 4, then 5, after that, if you want to go one step ahead i.e more than sqrt(25), then that square will exceed 25.
@@joydeep-halder u r talking about binary search ?
sabkuch chamak ra bhaiya. Keep continuing the good work.
00:01 Find First and Last
26:08 Insert Position
43:22 Sqrt(x)
Ram Ram Rohit bhai series bahut baddiya chal rahi hai aur sab kuch chamak raha hai apki wajah se best DSA corse on the internet thanks for the GOAT content man love&&respect++;
I was stuck on the sqrt(n) problem when you gave that in hw so when I checked the solution people were solving it using binary search but was not able to understand the code then but now
I think it will be made crystal clear by you bhaiya .
Thankyou bhaiya ❤❤
didn't got the answer kindly please explain
Solution 5: Count zeroes ✅✅
int start = 0, end = n-1, mid, firstIndex = -1;
while(start
Bhaiya i watch your videos daily with ongoing college and it will definitely give me an edge in Future so thank you and keep this going❤️
Day 31 done and dusted...... Awesome explaination...... #consistency
26:03 Optimization to Find First and Last Position of Element in Sorted Array 🚀🚀
We can check the adjacent left or right element matching or not, and this way we can avoid unnecessary search in left and right subarray.
class Solution {
public:
vector searchRange(vector& nums, int target) {
int firstIndex = -1, lastIndex = -1;
int start=0, end = nums.size() - 1, mid;
while(start
gaddari kar be
Best case will be O(1) but the worst case remains same
Also u can remove mid==0 and mid==numsize-1 as anyway in the next step start
1:03 pe hm int mid ko long mid kr denge to sb sai ho jaega...no need for extra if statement...
bhaiya ye ni kr skte h kya??
Lecture 23 Completed On 16-07-2024
In Every video there is something new to learn. ❤❤❤❤
49:42
class Solution {
public:
int mySqrt(int x) {
if(x==0||x==1)
return x;
int start = 1,end = x/2,mid,ans;
while(start
Thanks bhaiya for this amazing course
Bhaiya i am in class 9th and your teaching methods are so good that i got to know every topic crystal clear . I am watching your videos from day 1 and i will definitely complete the 180 challenge
By Abhay Deep
beta boards par focus kro ye kha aagye ho aap.
@@devprajapati5673 skill zyada imp h boards se
@@devprajapati5673bhai feka raha hai vo
@@devprajapati5673sahi bola bhai yisko malum nahi coding round ke phele amplitude round hota hai
@@dontreadmybanner2002 yup
HW Solution 4: Kth missing postive integer. ✅✅
int start = 0, end = arr.size()-1;
while (start
Aapne youtube pr sbse best pdya ..ithe sare questions bhot ache smajae...
Thank u Bhaiya apki wajah se meri DSA acchi ho gai hai..
1:09:54
//Count occurrences
class Solution{
public:
/* if x is present in arr[] then returns the count
of occurrences of x, otherwise returns 0. */
int count(int arr[], int n, int x) {
int first = -1,last = -1,mid;
int start = 0,end = n-1;
while(start
2:19
class Solution {
public:
vector searchRange(vector& nums, int target) {
vectorans(2,-1);
if(nums.size() == 0)
return ans;
int start = 0,end = nums.size()-1;
int mid;
while(start
Question - 2 34:00 crux of this problem is " target says:- merse badaa number may be mera position occupy kiya hua h so let me consider that in my answer variable aur merse chhote number se mujhe koi dikkat nhi h"
Bhai count occurence ka code bata do ? Mera error aa rha hn😢
@@Billy-gd1rm Bhaiya ne bahut achhe se samjhaya h. ek baar aur rewind kar ke dekho...
Basically is question me two times binary search lagana h one for first and one for last...
do these steps for both the search :
1. apply binary search and find the target element and consider in the answer.
2. Don't terminate the loop find in left and right for respective reaches.
3. keep finding till while loop end.
4. This will give you leftmost and rightmost index of that element for the respective search
this is the code you may refer :
//User function template for C++
class Solution{
public:
/* if x is present in arr[] then returns the count
of occurrences of x, otherwise returns 0. */
int count(int nums[], int n, int target) {
// code here
//first occurance
int start=0,end=n-1,mid=0,first_index=-1;
while(start
@@Billy-gd1rm explain the error
you can refer this code:
//User function template for C++
class Solution{
public:
/* if x is present in arr[] then returns the count
of occurrences of x, otherwise returns 0. */
int count(int nums[], int n, int target) {
// code here
//first occurance
int start=0,end=n-1,mid=0,first_index=-1;
while(start
@@Billy-gd1rm i have reply 2 times but i don't know why its deleted autometically
ohh got it.. i wrote the code here which is why it deleted...
what the error you are getting?
1:05:00
just asign ans = 0 while declaring.
bhaiya aap se ek request tha ki jab aap questions batate hai toye bhi bata diya kariye kaun kaun si company me pocha gaya hai
Thank you so much bro❤❤❤. Aap hamare liye 3 baje lecture record karte ho ...❤❤❤
Sqrt(n) wala phela code hua jo mai thoda apka logic dekh ke khud se banaya aur khud se samjh gaya ki isme errors aayenge toh usko kaise handle krna h INT MAX ka output kaise print krwana h ❤
Thanx bhaiya apki videos se sirf theory nhi balki bohot logic lagana bhi sikh rha hu padhai me bhi itna logic nhi laga pata 😂😂
1:03:17 yes bhaiya aur maine phle hi samjh gya tah🥳🥳 thnku bhaiya
Your teaching style is amazing😊
In square root question why not simply initialize mid variable with double.
I did it and it passed smoothly
Brother kya tum leet code pr question solve krte ho??
Subscription le rkha h leetcode ka???
@@nikhilgupta000 solve karta hu but subscription nahi lia hu
@@mr.perfect7925 kaise kra h brother
Mujhe bhi janna h
@@nikhilgupta000 follow striver sheet
Congratulations bro for 100k , I'm with you when it was 64k
excellent teaching for develop code and i thought no any one better than u sir❤
bhaiya aapne toh arrays pe zada problems nahi karaye kya aap woh baad mein kariynge kya?
Solution 7: Cube root of a number.
if(N
why did you initialize end with N/4?
best explanation i have seen on binary search.
bhiya sqrt wale q me jab hum (mid * mid ) karenge to wo int ki upper limit k bhr b to jaa skta h naa
PS :- ha aapne cover krdiya wo cheeej baad me sry mene dekha nahi tha
00:00 Fint First and Last element in a sorted array
09:11 Code part of First and Last Element
20:40 t.s
26:20 seond question
bhaiya time complexity for the linear approach of the root funcn is root n right..?
and yes bhaiya graphically ek baat aur sochi ki rootn ka graph is always above lnx thus time complexity ke terms mein binary search lagana is better
Bhaiya dout support ka kya hua!??
Mene multiple times aa same chiz comment bhi ki different videos pe pr koi reply nhi aata.
Mene subscription liya hua hai pr jo links aape provide kiya he bo khulte nhi or aap new link provide krbate nhi mene aase a aspect nhi kiya tha!
In second question of search insert position can we return start after running the whole while loop then by checking the condition if start > end , in case if the element is not found . Then also our problem will be solved
Sir you have great problem solving skills 😊
Bhaiya in 2nd Q initially I took index= -1 ...and rest of the code is same but when si=mid+1 , I updated the as index =si; means mid pr to possible nhi h but mid+1 pr to ho skta h na.....so is it a correct approach???
✅Completed_Lecture23....19-Nov-2023
Bhai tu world Cup ke din bhi padh rha tha Khair jane de purana jhakm taja kar diya😭
Bhaiya Vs code me kese solve kre while loop 2 baar likhna h kya
Bhaiya can we take our mid long long instead of int?
45:50 Time Complexity is O(root N)
Please explain
Day 31 of #180DaysOfCode completed
In Today's class, the observation is that how much is essential to get the approach first and then code because all the game of approach code written can be done in a few minutes.
K th missing number using linear search .
code :
#include
using namespace std;
int main(){
int size , arr[100] , k;
cout > size;
cout arr[i];
}
cout > k;
int n=0 , i=1;
while(n
27:24 bhaiya maine ise min heap se solve kiya hai
int searchInsert(vector& nums, int target) {
// min heap
priority_queue pq;
for(int i=0; i
Bhaiya Square root wale question ki linear approach ki Time Complexity O(root(n)) hogi
at 55:00 ....
class Solution {
public:
int mySqrt(int x) {
return sqrt(x);
}
};
simple 😂
MY APPROACH FOR THE SEARCH INSERT POSITION
int n=nums.size();
int start=0,end=n-1;
int mid;
while(starttarget)
{
end=mid-1;
}
else
{
start=mid+1;
}
}
if(nums[mid]>target)
return mid;
else
return mid+1;
my mathematics teacher used to say one thing
"apni walil sabko achhi lagti hai"
although aapka metjod was easier to understand but apna method sabko best lagta 😂😂❤
Bhaiya aap bahut hi ache se samjha te ho bas aise hi 180 day tak chamkate rehna 😅😅❤
Index= mid+1 bhi kr sakte the jab Target value bada ho
square root
int main()
{
int num;
coutnum;
int start=1,end=num;
int mid,index;
while(startnum)
{
end=mid-1;
}
if(mid*mid
Thanks for explanation . amazing
🏃♀Day 8✅
Thank you so much bhaiya for this great work...
Great Explanation Sir🙏🙇♂✨✨💖💖
Solved All 7 Questions given in the description.
sir while loop se mat kra kariye if else if more understanding than this
Bhaiyya! Chamak gaya acchese✨✨
Can't tell, how good your course is?
August 3 : Day 3 of Revision
Questions on Binary Search Done ✅✅✅
In 5 questions we found the first and last position of an array after doing this (first -last) + 1
And get the desired output 🎉🎉😊
Another best way to not have error is mid=start/2 +end/2
raapchik content ,guyz pls do share with your frnds, bcz likes != 💎💎📄📄,so please like and subscribe after watching the vdos of neggi bhaiya❤❤
valo explain korle rohit da
Great sir❤
Bhaiya second wala questions k 36 test cases he pass horahe hain sirf .
Bhaiya Maza++ ❤
26:20 second question
sqrt of x by using normally loop time_complexity:- O(n).
mere me TLE aa rha h same logic se aisa kyu ??
Done Bhaiya... 31/180 ✅
Pura chamka diya bhaiya🤩
Where is discord link ?
Time complexity o(n) hai na. 45:45
I think O(sqrt(n)) hogi kyuki hum bs sqrt n wle element ko lere hai
saach bolu to aisa content abhi youtube me aya hi ni hai fadu level ka concept koi hau ni takar me apka bhaiya
2 cr package bande ne aise hi ni phod rakha hai
Thank you Bhaiya
aaj Bahot maja aaya.
Amazing lecture
Ram Ram bhaiya maja aa gaya
Bhaiya we can easily write the program of square root like this
#incude
#include
Using namespace std;
Int main ()
{
Int n;
Courtn;
Int a=sqrt(n);
Court
there is a condition not to use in built operations
Thank you so much sir🥰
#180DaysofCode
Day -31/180 Lecture -23
Successfully Completed ✅✅✅
Anyone for pair prograaming???
Yea sure
int arr[7]={1,2,3,3,4,5,3};
int n=sizeof(arr)/sizeof(arr[0]);
int i=0 , j=n-1 , x , fp=-1 , lp=-1;
coutx; cout
31/180 done , thanku so much bhaiya
bhai kabhi kabhi time dekha diya jise hum motivate bhi hogye kre ki bhai itne late tak humre liya mehant kr te hai
26 June ❤ Completed
count zero
int countZeroes(vector &arr) {
// code here
int mid;
int start =0;
int end =arr.size()-1;
int ind;
while(start0){
start =mid+1;
}
else{
ind =mid;
end =mid-1;
}
}
return (arr.size())-ind;
}
Bhai count occurence ka code bata do ? Mera error aa rha hn😢