All Notes of this Lecture : drive.google.com/drive/folder...
Пікірлер: 1 700
@closer96893 жыл бұрын
Sir thoda deep explanation hona chahiye . Especially for those who are really very new to coding . Kyoki hmare liye yeh sb kuch bhot nya hai to hme yeh btaeye ki apne hr ek particular coding line Kya Soch kr code ke . Videos or zyada discriptive honi chahiye , especially while dealing with the questions. It's a humble request🙏. Guys do like if you also think so✌️.
@onkarnagarkar46933 жыл бұрын
I came up with a simpler solution for Q2 subarray with given sum : code is at the end if you want to jump to solution! variables: first index of the sub array to be printed is "first_idx" and last index will be "i" itself. Current sum as "sum" and input sum as "s". example array: 1 2 3 7 5 initialized= first_idx as 0 (starting index of the array) sum=0 process: using for loop, we first do the usual sum update i.e. sum=sum+a[i]; following are the possibilities: if (sum==s) means we have found the array where sum=given sum i.e. "s". cout
@onkarnagarkar46933 жыл бұрын
@@chhitizekumar1217 Yeah there were some corrections. I have updated the code. I could do it without while loop to keep the time complexity minimum. Have a look! void sum_s(int arr[], int n, int s) { int first_idx=0; int last_idx=0; int sum=0; int i=0; for(i=0; i
@chhitizekumar12173 жыл бұрын
@@onkarnagarkar4693 Yeah it's good apporach. Thanks for sharing.
@blazyhell45533 жыл бұрын
@039 Raunak Singh You are demotivating, go away!
@AjayYadav-um1oj3 жыл бұрын
// Given an unsorted array A of size N of non-negative integers, find a continuous // subarray which adds to a given number S. #include using namespace std; int main() { int n; cout n; int arr[n]; for (int i = 0; i < n; i++) { cin >> arr[i]; } int st = 0; int et = 0; int s; cin >> s; int sum = 0; while (st >= 0 && et < n) { if (sum == s) { cout
@waseematel80652 жыл бұрын
every person who is watching the videos regularly don't get panic and say explain every step of code and all because as you continue the upcoming videos you will realize that these question where very silly at this point of time coz its so basic that you wont even need to refer to anything else so just watch it and solve problems on daily basis. If you still think its getting difficult then just refer to some other youtubers or any source of website about the particular topic, clear the concept and come back to the playlist as i did during the time of functions. Do what ever it takes to grasp and understand the concept just do not give up thinking "i am not made for coding" and all that negative things ! one day all of the time you invested will give you the result. Best of luck.
@Ankit__Mishra3 жыл бұрын
Best video with worst explanation You are explaining what you are doing. You should explain why you are performing such steps.
@BackToBoi2 жыл бұрын
Bilkul sahi bola bahi q-2 ke steps to samaj hi nhi aaye, didi ji har ek step ko aache se batate hai. Kya apko q-2 ke steps samaj aaye?
@saranshgupta91192 жыл бұрын
@@BackToBoi na bhai
@agni72742 жыл бұрын
in the third question of subaary withgiven sum , why in the first while loop we take cout
@yupp_harish39362 жыл бұрын
right
@hriteshshanty2522 жыл бұрын
Sahi baat hai explaination bhht poor hai
@doraemonsharma93183 жыл бұрын
Sir, you are a very good and pro coder. But we are at low level now. And you're teaching in a way that we are unable to understand because you are teaching in high level. Although I appreciate you're giving a really great content, yet due to your speed of teaching and also way, some of us are not able to understand. Kindly, please look into it. Will be helpful for all.
@syedafreen26423 жыл бұрын
true
@pottalokesh20393 жыл бұрын
Yes bayya
@rishabhthakur22703 жыл бұрын
True what i suggest is watch it at 0.75x speed Might help
@anuragsinghdangi9853 жыл бұрын
True
@puneetsingh96783 жыл бұрын
accha sikhaya hai agar solution dekhne se pehle 20-25 mins khud se try kro to asani hogi smjhne me. I really like this bhaiyya's teaching as well
@067_subharajmishra83 жыл бұрын
There is no doubt that this course is very well-designed to help the student who aspired to get into Product Based Company. But however, there is a small miscalculation that can later turn into a major flaw. This flaw is that it isn't helping the beginners as much as it should. The questions are very overwhelming and it will compel the beginners to feel demotivated and leave the course in the middle. My suggestion would be that if you could teach all the concepts and give us basic to intermediate questions to practice. After the completion of the course we will do the high-level questions such as those of MNC's etc. yours truly raj mishra
@aryanverma78003 жыл бұрын
this is a crash course for final year students with less time in hand ...for basics , one can follow c++ by saurabh shukla and practice hackerrank basic problems
@manavkampani83673 жыл бұрын
just a suggestion brother you shouldn't be all dependent on this course, google your doubts and do your own research when stuck. This is how one grows in this field.
@abhijitpanda5242 жыл бұрын
Honesly these questions and Explainations are really good I am not a beginer , but I can understand your problems , Because you are not solving the brute force method but the more complex but Optimised method , you are feeling a bit demotivated that you can't code Try to solve the easiest Brute force method 1st then see this Optimised Solution
@sarthakkhare46002 жыл бұрын
You are right I am not a beginner but questions are quite good but the coding explanation is like to make the pizza without adding usefull ingredients in it cheese...
@arpitakar3384 Жыл бұрын
engineers with brain and patience can understood
@beasty7733 жыл бұрын
aman sir question is clear and the dry run concept is also clear but when it comes to coding everything just goes above her heads.
@codeWithPatience2 жыл бұрын
Vai 1 st wala Ka code send Karna
@abhisheksaraswat6632 жыл бұрын
@@codeWithPatience #include using namespace std; int main() { int n,i; cin>>n; int a[n]; const int N=1e6+2; int idx[N]; int Min=1e6+2; for(i=0;i>a[i]; } for(i=0;i
@codeWithPatience2 жыл бұрын
@@abhisheksaraswat663 Thanks vai
@priyanchauhan2 жыл бұрын
Merko to lagta ha ye coding baski hi nhii ha mera
@agni72742 жыл бұрын
in the third question of subaary withgiven sum , why in the first while loop we take cout
@mehboobahmed8923 жыл бұрын
" questions karna to ek bahana hai Programming me sochte kaise hai ye aap ko seekhana " Thanks a lot..
@twi44582 жыл бұрын
Absolutely Agree
@saranshgupta91192 жыл бұрын
Waah waah Waah waah
@shreyaschavhan55223 жыл бұрын
01. First Repeating Element - [0:23] 02. Subarray with Given Sum - [7:51] 03. Smallest Positive Missing Number - [16:05]
@ritikshrivastava94423 жыл бұрын
har video me yahi kar
@prasadbhalerao85562 жыл бұрын
@@ritikshrivastava9442 Tuze kya problem he be
@sangamgorde9061 Жыл бұрын
Thank you bro .
@tanugiri532 Жыл бұрын
Thx 😊
@simranbansal50812 жыл бұрын
Thank you apna college this dsa playlist is so good, I watched just two videos from your channel and already so many topics are clear, regarding array, subarray, and time complexity.
@rahulsaw88383 жыл бұрын
Diff. Approach for first repeating element are:o(n²),o(logn),o(n) space,o(n)without space in consideration of constraints
@ShawnFrost_72 жыл бұрын
Here is a shorter code for the subarray sum problem having the same logic : (open in pc to view it properly) #include using namespace std; int main() { int n,st=0,end=0,sum,csum=0; cin>>n; int arr[n]; for(int i=0;i>arr[i]; } csum=arr[0]; cin>>sum; while( st
@akshatpandey85712 жыл бұрын
Is this working fine?
@ShawnFrost_72 жыл бұрын
@@akshatpandey8571 yup the logic is same as in video and it worked perfectly on the test cases i gave it to run. ( Tell me if there are any boundary conditions that I missed, I will edit it )
@shreyanshmalviya49683 жыл бұрын
My type of solution to 1st question is #include #include #include using namespace std; int main() { int n; cin>>n; int arr[n]; int idx[1000]={-1}; fill_n (idx, 1000, -1); int minidx=INT_MAX; for(int i=0 ; i>arr[i]; } for(int i=0; i=0 && idx[value]
@unknown_u_know Жыл бұрын
❣️
@shambhavikhare98503 жыл бұрын
Great video. Thanks for this series
@sanchitraj5823 жыл бұрын
Thanks Bhaiya for wonderful Explanation ❤
@abhayranjan58783 жыл бұрын
Plz conduct dout session class on each Sunday 🙏🏻🙏🏻🙏🏻🙏🏻🙏🏻 Bcz we r facing problems in few programs,nd if the dout r not being cleared we will be in more trouble❤️❤️
@abhinavagarwal20453 жыл бұрын
you can join my telegram group named "apna doubt" we have made to discuss the doubts
@arabindaacharya9644 Жыл бұрын
For question no 1, memory consumption is very high. As we are using array of 1e6. Instead we can use a map to store traversed element
@mimadhali1157Ай бұрын
Thank you for the clarification. My code was not running because of this issue
@bosesj2 жыл бұрын
in the last problem (and also the problem like that), instead of creating an very big array, we could just create an array of length == maximum number present in the prev array + 1 (maximum+1 cuz if length of array is equal to the max num then the array itself ll not include the max index itself), now we dont need to sort or do something else for that to find the biggest number, we could just take the maximum value (that ll be on the main array )while taking input for the main array. #edited@9thSep
@ashlex75342 жыл бұрын
woahh!! what a genius bhai. making that large array was very overwhelming. Thanks a bunch!
@j__x__c88232 жыл бұрын
for Q1. isn't initializing -1 to an array of size 10^6, gonna take a lot of time.
@sankalpupadhyay66322 жыл бұрын
No, It will only take O(N) time
@yathin88342 жыл бұрын
initializing is liner i.e O(n)which is still less than 10^8 which is the allowed time complexity
@sumanthhegde51482 жыл бұрын
Use Vector const int r=1e6+2; vector idx(r,-1); and you'll get a vector(dynamic array) with -1 initialized.
@santanu292 жыл бұрын
For the subarray sum problem. There is no need for extra loops. just 2 are enough. #include "bits/stdc++.h" using namespace std; int main() { int n,s; cin >> n >> s; int arr[n]; for(int i=0;i> arr[i]; int i=0,j=0, start=-1, end=-1; int sum=0; while(j s) sum -= arr[i++]; if(sum == s){ cout
@ujwalkachade70663 жыл бұрын
9:43 two pointer algorithm work karne ke liye array sort hona jaruri hota hai na 🤔🤔 but question me strictly unsorted array bola hai
@codetogether24x73 жыл бұрын
Same doubt is with me
@mohammadafnan87413 жыл бұрын
we can do it with count sort at well na?
@parthapratik78873 жыл бұрын
@@mohammadafnan8741 i think ya inclusion exlusion principle ki trh h
@parthapratik78873 жыл бұрын
i think ya inclusion exclusion principle ke uper based h
@samarpratapsinghshekhawat8532 жыл бұрын
@@mohammadafnan8741 @Mohammad Afnan original array will get messed up on sorting and we would not be able to return the correct index boi
@akhilnair16493 жыл бұрын
Sir,In the third problem (the one in which we had to find the smallest missing positive no) can we solve the problem with constant space rather than using bool array and also in o(n) time complexity(if so can you make a video on it).The content is superb. I havent seen any c++ course which includes problem solving anywhere in the youtube.Thanks for the playlist!
@garvitjain26693 жыл бұрын
My Brain After Hearing The shayri In starting:- Waahh...wahhh...wahh....wahhh
@artirani38063 жыл бұрын
Sahi mein yahi toh sikha rahe h bhaiya hume..Question karne k liye sochna zaroori h..literally Wahh..Wahh..Wahh
@garvitjain26693 жыл бұрын
@@artirani3806 Correct!!!!!!
@HaiderAli-tb1qr3 жыл бұрын
Same
@snehilsinha46893 жыл бұрын
par expectation k hisab se shayari tatti thi 😂😂. Maine socha kuch mastt hoga lol.
@sayantansinharay91613 жыл бұрын
@Apna College can you please start the playlist of competitive programming. I think I will help others who are intermediate.
@abhijitpanda5242 жыл бұрын
Honesly these questions and Explainations are really good I am not a beginer , but I can understand their problems , Because you are not solving the brute force method but the more complex but Optimised method , They are feeling a bit demotivated that they can't code
@dhruvpandey65022 жыл бұрын
100 percent true i am leaving the course in the middle because it is way too advance approach can u recommend me other cannel from where i can learn dsa
@anuragvermav6008 Жыл бұрын
Q1 0:23 first repeating element Q2 7:50 subarray with given sum Q3 16:05 smallest positive missing number
@proteanguy34113 жыл бұрын
Ye video badhia thi pehle se 😁 first question ki confusion ko chod ke 👍
@pranavgyara71402 жыл бұрын
22:48 I think in last for loop it must be iterating till i
@deepaksai36372 жыл бұрын
Hi sir,i am very thankful for your course but your level of explanation is enough for coders who are able to crack product based companies .Naming the course as beginners to advanced pls explain in detail or expose the people more to lower order questions before these.I stopped 5 times this course and came back again and again to learn something.
@sanchitraj5823 жыл бұрын
Your content are great . Evergreen 💚
@arka63023 жыл бұрын
I have a doubt in the second question(subarray wala). In line 33 we declared a nested while loop so how complexity is O(n) is now O(n^2) Please explain
@AbhayGupta-kd9rm3 жыл бұрын
Yes bro same question!!!
@rajchaulagain66033 жыл бұрын
The complexity is still O(n). Check once again!! the inside loop is implemented on Sum not on n. Hence O(n) time complexity.
@mjustboring3 жыл бұрын
let's see sum example: int count = 0; for(int i=0; i
@AbhayGupta-kd9rm3 жыл бұрын
@@mjustboring♥️😘
@yashshelar86052 жыл бұрын
@@rajchaulagain6603 thx
@HimanshuSingh-tu7ik3 жыл бұрын
bhaiya ne improve kiya hai sahi mein hats off for his efforts
@subhammishra3162 жыл бұрын
guys in last question we can do like this int one=0; for(int i=0;i
@anchitsri3 жыл бұрын
Thanks sir for such a nice representation of these questions. You have cleared all my doubt in these questions and also build a new strategy for thinking these type of question.
@madhusudananand90593 жыл бұрын
Urvi didi k lectures jayada ache se samajh aate hai please urvi didi se hi continue karwao
@krishnasingh12613 жыл бұрын
Ha yaar isko bhejo wapas
@krishnasingh12613 жыл бұрын
Mam ko hi bulao
@KundanKumar-uj2in3 жыл бұрын
@@krishnasingh1261 bhai ye pura team h jo work karte hain aapke liye kuch topic ye bhi karwate h kuch mam v so isliye concept samjhne ki kosis kro teacher does not matter how passonate u r thats matter
@krishnasingh12613 жыл бұрын
@@KundanKumar-uj2in exactly, we r passionate and thts y we want to understand it but we arent able to
@puneetsingh96783 жыл бұрын
@@krishnasingh1261 accha sikhaya hai agar solution dekhne se pehle 20-25 mins khud se try kro to asani hogi smjhne me. I really like this bhaiyya's teaching as well age ab topics hard hongi agr ye follow nhi kiya to koi bhi sikhae retain nhi kar paoge just a suggestion
@polymorphs3 жыл бұрын
This particular video of the playlist became the shows stopper...................moved one
@ASMR-bu8qc Жыл бұрын
I just love the approach that you used in the last question
@thebeats52342 жыл бұрын
Why we have made N integer as const?? is it possible to implement code without making it as constant?? And cant we use N=1e6 only instead of using 1e6+2???
@Ocean_77848 Жыл бұрын
for 2nd problem you may try #include using namespace std; int main() { int a[10]={5,6,4,8,9,3,25,4,10,7}; int i,j,sum; j=0; sum=0; for(i=0;i
@CruelCreations11 ай бұрын
O(n^2) complexity
@gensonic7 ай бұрын
😂🎉😮😮😂😮😅😅❤😂😮😊
@AshishKumar-ny4cq2 жыл бұрын
two pointer logic ko normally itne aasan logic to complicate kar diya if(sums) i++; Par rest aacha tha got to learn new things thanks...
@parthapratimghose1733 жыл бұрын
did one with o(n) will share the solution soon what you have done is crossing on^2 in one loop which can cause error ! my main loop is start=0,end=1;final1=start,final2=end while(start
@devanshgupta52813 жыл бұрын
Bhayia loving this content. A request please also make videos on main subjects also(dbms,cao...).
@483_saurabhjindal63 жыл бұрын
study cao from bharat acharaya
@483_saurabhjindal63 жыл бұрын
study cao from bharat acharaya
@jubinben45382 жыл бұрын
According to the logic for the last question, if no smallest +ve element is missing from the array the answer won't be -1, it will be largest element in array "a "+ 1.
@vishaljha50712 жыл бұрын
how?
@abinvarkey23312 жыл бұрын
yeah i thought about that too, and according to his code, the ans will not be -1 because the check is if(check[i]==false) ans=i; so if array has all positive numbers till the end of a[ ] then next check[i] will give false for number not in a[ ] (here i is beyond a[ ] limit)
@harshithp30073 жыл бұрын
for(int i=0;i=2){ cout
@yagamilight082 жыл бұрын
sir in the second for loop if no such num is found till 'n' length then it will automatically give the element which will be one more than the max of the array because loop is running till N...perhaps it should be n instead.(in last problem)
@shreyansh27292 жыл бұрын
my approach for 2nd ques. (subarray with given sum): int main(){ int n,s; cin>>n>>s; int arr[n+1]; arr[n] = 0; for(int i=0; i>arr[i]; } //main logic (optimised approach) int j=0; int sum =0; for(int i=0; i
@MyCodingCollege Жыл бұрын
//Q.1 Frequency of an element in an array, Consider the repeated element which comes first. #include using namespace std; int main() { int n; coutn; int arr[n]; cout
@alonegaming3424 Жыл бұрын
@shahab bro mera 1 question wala code run he nhi ho raha h vo khali input le raha h arr[n] ke liye aur end ho ja raha h
@IrfanAli-so5hh Жыл бұрын
Can u please tell me what is this "1e6"?
@akshaykshetrapal837211 ай бұрын
@@alonegaming3424 ha sahi bola nahi run hora
@ayushpratapsingh25403 жыл бұрын
The last question has been made very complex to understand. I have a shorter and simple approach to it. First sort the array in ascending order and then write this code: j=1; for(i=0;i
@shrutigupta93193 жыл бұрын
Awesome Series!!
@kerinpithawala3243 жыл бұрын
Another approach for small positive missing number: 1) Sort the array. 2) start a while loop for i=0 till n: a. if condition array[i]>-=0 if the difference between the present array element and its next element is not equal to 1 then return array element+1
@raniwalafabrics54683 жыл бұрын
TLE error aegya
@harshdeeppandey89022 жыл бұрын
your approach is right but complexities are the main boss in algos
@shubhamp_web2 жыл бұрын
@@harshdeeppandey8902 right
@DivyanshuKashyap-op3mp Жыл бұрын
that will only work if the elements are arranged in order
@onkarnagarkar46933 жыл бұрын
I came up with a simpler solution for Q2 subarray with given sum : code is at the end if you want to jump to solution! variables: first index of the sub array to be printed is "first_idx" and last index will be "i" itself. Current sum as "sum" and input sum as "s". example array: 1 2 3 7 5 initialized= first_idx as 0 (starting index of the array) sum=0 process: using for loop, we first do the usual sum update i.e. sum=sum+a[i]; following are the possibilities: if (sum==s) means we have found the array where sum=given sum i.e. "s". cout
@mansha65663 жыл бұрын
same I did
@shivambajpeyi90083 жыл бұрын
Thanks bro
@shivambajpeyi90083 жыл бұрын
I agree it's working fine for s=12, but for s=15 it's not working, plz help...
@shivambajpeyi90083 жыл бұрын
@@mansha6566 I agree it's working fine for s=12, but when I tried for s=15 it's not working, plz help...
@mansha65663 жыл бұрын
@@shivambajpeyi9008 I DID IN THIS WAY : while(j-i
@ShubhamKumar-rt4jy3 жыл бұрын
In third program when we do i=0 istead of i=1 in last loop its show error. Can i know why this is so.
@aryanshmalviya10673 жыл бұрын
Isse accha doubt solving abhi tak toh kisi ne nahi kiya , thanks bhaiya!!!!!!!!!
@prathamshah59293 жыл бұрын
Sir but in 2 pointer approach the array must be sorted?
@ritikshrivastava94423 жыл бұрын
14:32 you used two while loops so time complexity is O(n square) then what is the significance of using this logic we can also done in by using two for loops and time complexity is also O(n square)
@prathamgwari90273 жыл бұрын
I am also stuck here. Someone please explain.
@unigtechy41303 жыл бұрын
@@prathamgwari9027 at the second """"while""" just replace with """if""" ||your code just works fine and the time complexity will be O(n)
@unigtechy41303 жыл бұрын
at the second """while""""" just replace with """""""""""if""""""|||| your code just work fine and the time complexity will be O(n)
@hmswrth3 жыл бұрын
even with 2 loops here, you'd only get O(2n) in the worst case which is O(n). Dry run the test case against the code. Run it against a=[35,1,31], s=32 to understand it better.
@pankajvishwakarma31243 жыл бұрын
@@hmswrth first you check for a[ ]={2, 3, 4, 9, 5, 4, 1}, s=10 . it will come O(n square) which is in worst case scenario. but in brut force approach it will always O(n square) in all three cases , therefor this approach is optimal.
@computersciencelover31772 жыл бұрын
Thank you and God bless you sir 🙏
@akshatthakur59673 жыл бұрын
Is it that if required time complexity is of order n then we avoid nesting of loops but we can code seperate loops?
@amardsalujasingh40943 жыл бұрын
App best hoooo or Yeah Fact hai Fact hai Fact hai 😂
@artirani38063 жыл бұрын
@amardsaluja singh Bikul sahi kaha😇🤟🤟
@akhilsukhnani26593 жыл бұрын
A better approach that can save space complexity as well, in the first question (finding the minimum index of repeating element is):- #include using namespace std; int main() { int n; int maximum=-1; cin>>n; int arr[n]; for (int i = 0; i < n; i++) //Taking array input { cin>>arr[i]; maximum = max(arr[i],maximum); } int minm_index = n; int arr1[maximum+1] = {0}; for (int i = n-1; i >= 0; i--) { if (arr1[arr[i]]==1) { minm_index = min(i, minm_index); } else { arr1[arr[i]]++; } } cout
@pranshu_awasthi2 жыл бұрын
You're clearly using another array arr1 , how does that save space ?
@devanshkushwah63352 жыл бұрын
bro no you are not saving the space as you are doing operation inside the input section, u are not allowed to do so
@anantsaxena78762 жыл бұрын
your code will produce output if someone gives a value more than 10^6 whereas it should display error for exceeding the limit
@vrandakansal59403 жыл бұрын
Approch on both questions is amazing...mene socha hi ni tha aaisa bhi ho skta h..😁 Thanks a lot...bhaiya
@yashvisoni58193 жыл бұрын
sir bohot hi acchi video thi or bohot hi simple way me solve Kiya bcz mene bohot sari website se problem ko Dekha but ye bohot hi simple way me solve karvaya hai so thank you, sir
@ankitkumarpathak67683 жыл бұрын
what about when 2 or more sub array having same sum ??
@parvshah64173 жыл бұрын
//return the smallest index of the repeating element(problem 1) #include #include using namespace std; int main() { int n=0,i; coutn; cout
@it026sanjanadaki22 жыл бұрын
Hey when I saw the problem I first thought of nested for loop outer loop starting from 1 to n-1 inner loop from 0 to i and applied condition if arr[I]==arr[j] I stored value of j in my count variable thn applied min function It's right to think either way??
@yogeshjangra28222 жыл бұрын
@@it026sanjanadaki2 yes
@ayushkumar6575 Жыл бұрын
bro 1st wale ka answer to hames 1 na aayega kuyki 5 ka index 1 hai na to ye bhaiya video me 2 q bol rahen??
@b_14_charvykoshta523 жыл бұрын
phenomenal !
@aayushraj47333 жыл бұрын
Bhaiya aap asse pdha rhe jaise hm sb ko bht Kuch aata ho
@shayankabasi1603 жыл бұрын
A true exceptional course in the whole internet - waiting for whole series to upload
@RadixYT2 жыл бұрын
10 baar try kr lia 1st problem ka he solution smj nhi rha wasted like over 4 hour
@ajaykumartyagi51052 жыл бұрын
Same with me the problem is with tutor not us These are the tough programs but not that much ,after 2-3 times we all will get it.
@karthikbs97652 жыл бұрын
bro he also initialised wrongly it must be int_max not -1; if we need min while initiating with -1 is literally wrong
@anandkumarsingh14042 жыл бұрын
ye probleam ko itna long kyu la gaye h pata nahi simple ma vi to ban sakta h na
@priyajha9442 жыл бұрын
@@anandkumarsingh1404 @Anand Kumar Singh Simple (Brute force) method se bhi ban jaaega problem but its time complexity would be O(n²) which will exceed compilation time limit for larger size of n. That's why to make the program more efficient (to reduce the time complexity of the program to O(n)) we have used this approach.
@user-tm5pw6qe8j Жыл бұрын
another method to do last question- #include #include #include using namespace std; int32_t main() { int n; cin>>n; int a[n]; for(int i=0;i>a[i]; } int mn = INT_MAX; for(int i=0;i0) { mn = min(mn,a[i]); } } cout
@shreyanshmalviya49683 жыл бұрын
instead of using for loop and increase time ,you can just use fill_n (idx, 1000, -1); function to declare all the elements of the array as -1.
@deepakparwani63433 жыл бұрын
memset se bhi ho jyga bhai
@shreyanshmalviya49683 жыл бұрын
@@deepakparwani6343 Yes there are tons of ways to do that.
@Dr.Funknstein3 жыл бұрын
Dude the way you speak is awesome, I've never had this much fun solving questions. oh and initializing N as 1e6+2 yields some error that's not prompted at runtime, I just get thrown out of the program as soon as it runs but I could fix that by changing it to 1e5. What could that be about?
@ProductionReadyApp3 жыл бұрын
Same problem happening with me in vs code.
@mukulgupta83293 жыл бұрын
Yes same here and its only happening in VS Code Windows
@mukulgupta83293 жыл бұрын
@@sayandutta9506 K thanks But it didn't happen anywhere else so I am wondering why only in VS Code
@mukulgupta83293 жыл бұрын
@@sayandutta9506 I tried your way but its still not working in my program. I found another way that is find the max number in the array using a loop and then make it the length of the index array. It won't change the time complexity but reduce unnecessary storage for small inputs. PS first increase it by 2 but still the memory maxes out when I input a number bigger than 519064
@Mrugal73 жыл бұрын
Thanks For This , i have been facing this difficulty since 4-5 Hrs
@pranchalkushwaha74073 жыл бұрын
ek video ko achhi tarah se samaj kar code karne me maximum 1 se 2 din ja rha hai ... kya itna time sahi hai.....
@murarichaudhary5602 Жыл бұрын
Sum array with given Sum-->> we can do this in n time by this approach #include using namespace std; int main() { int n, S; cin >> n; int arr[n]; for (int i = 0; i < n; i++) { cin >> arr[i]; } cin >> S; int st = 0; int en = n; int nowt = 0; string calc = ""; int CrrSum = 0; int ct = 0; while (st < en) { CrrSum = CrrSum + arr[st]; if (CrrSum > S) { //we are re initilize perimeters ct++; st = ct; nowt = st; calc = ""; calc += to_string(nowt+1); CrrSum = 0; continue; //we are continur here beacause st will further increase at bottom } else if (CrrSum == S) { calc += " "; calc += to_string(st+1); break; } st++; } cout
@MahipalSingh-tc8fm2 жыл бұрын
the 1st que can be done with almost 0 time complexity and very less space complexity(Even u can save the time for taking input in array) here's my approach : #include using namespace std ; int main(){ int n,k ; cin>>n; unordered_sets; int i =0; for(i;i>k; if(s.find(k) != s.end()){ cout
@ronakbothra63713 жыл бұрын
i think there is some error at 19:18 on check[1] and check[2] , t and f are misplaced there :)
@g8dboyplays7903 жыл бұрын
yes i noticed that too
@lifeoeshita3 жыл бұрын
I think not, because here we also placed true and false like a[i] = i, mean a[2] = 1 that's why index 1 should true. Check the last code.
@nitishverma14843 жыл бұрын
It's not correct and when you change the input in array it will not work
@lifeoeshita3 жыл бұрын
@@nitishverma1484 2. By iterating over the array and marking non-negative a[i] as true i.e. if(a[i] >= 0) check[a[i]] = True just check this step 2 on the given material
@shivamthakur73243 жыл бұрын
@@lifeoeshita as per the explanation given in viDeo , itreat over the array and mark non negative as true , so at I=5 after all the iteration of array 0,-9,1,3,-4,5 .check array should look like T,F,T,T,F,T so by that we will getting index 1 as smallest missing no.
@devanshkushwah63352 жыл бұрын
time complexity in 1st questions is exceeding according to the constraints
@pranayjain._ Жыл бұрын
A very simple code for Q.2. int main() { int n=5,s=12, minid= -1 , maxid = -1; int a[5]={1,2,3,7,5}; for(int i=0;i
@rahulgoel85723 жыл бұрын
what is the use of while (js) and all that
@rahulgoel85723 жыл бұрын
in question subarray with given sum s
@rajarshimondal82472 жыл бұрын
For the 2nd Problem.... I want to ask two things..... 1) Here nested while loop is used and that might make the code of O(n²) order.... Please explain it. 2) Is the part before 2nd while loop needed? (I mean till the end of 1st while loop)..... Cause the part after that is running fine and gives answer in all cases...... And I think that 1st while loop is a special case of 2nd bigger while loop only...... So is it needed?? Please reply 🙏🙏🙏🙏
@meme_eternity Жыл бұрын
1) It will not make them O(n²) order u just dry run on any example made by ur self and u will be able to get how and why i am saying this. 2) Not able to understand your doubt
@ChillVibes_473 жыл бұрын
लाइव क्लास आने का तो बहाना है ।। हमे तो अपना कॉलेज पे जाना है ।।।
@AmanSingh-oc5tu3 жыл бұрын
bhaiya no word this all c++ course dil sai love uhh and thnk yu so much
@niteshguleria99013 жыл бұрын
In 4:25 I have a little better version . Instead of line 16 bcs it will create an array with huge size y not give : for (int i = 0; i < n; i++) { cin>>array[i]; maxElement=max(array[i],maxElement); } while taking input we will get to know the maximum element and then make array (line 17) int newArray[maxElement+1]; the size will be according to max element. That will optimize it a little more.
@garvitsingh25933 жыл бұрын
this series is helping so many of students that even comments in comment's section cant explain its importance .. thank you sir for guiding us and helping us!!
@rutvikrana5123 жыл бұрын
Approach Of The First Question Can Be Optimized. #include using namespace std; int main(){ int arr[] = {3,4,5,6,7,8,9,6,7,9}; int n = sizeof(arr)/sizeof(arr[0]); int temp[1000] = {0}; int index = n; for(int i=n-1;i>=0;i--){ if(temp[arr[i]]==1){ index = min(index,i); } else{ temp[arr[i]]++; } } std::cout
@37omgumgaonkar283 жыл бұрын
Bhaiya I have a problem while running 1st problem the code gets run automatically without taking input I shared you file pls check it out drive.google.com/file/d/14tDq_lcSKDZU27xTo9uCo060J3LmIebO/view?usp=drivesdk
@shreyanshmalviya49683 жыл бұрын
@@37omgumgaonkar28 Hey there I am Shreyansh Malviya . I am 15 years old. I have fixed you code. the main causes it was not working were:- 1. for INT_MIN the library needed is so I added it. 2. you forgot to add library needed for cout and cin. *don't worry about the libraries you can add the #include "bits/stdc++" to add all the all necessary libraries in the video also he added the same library 3. on line no. 26 you wrote 1e6+2 but i replace it with 1e5+2 I also don't know why it didn't worked with 1e6+2 4. There were 2-3 bracket errors; because of misplacing brackets the link to the correct answer is docs.google.com/document/d/1bd44R_ycM8tMEzjxoYQJ5BwvH_bhh4maA4bqFTbQlag/edit?usp=sharing Glad to help you :-D
@harshchoudhary_57742 жыл бұрын
@@shreyanshmalviya4968 thanks bhaiya i have same problem 6 months ago😊.
@vaibhavsharma84653 жыл бұрын
Bhaiya mja aagya in questions ko krke... Aapne bhot accha smjhaya h.... Ekdum dhaansu😃😃
@muhammadshoaib1893 жыл бұрын
Bhayia G !! Sub Array Sum Wale Problem ki time complexity for worse case Kia baan rahi hai!! I think it's n2 (square) .. Koi Aur hi help kardo
@total_53003 жыл бұрын
sir i want to say that please mentain your speed bcs i did not understand how is working our code thanking you
@akshatvyas25943 жыл бұрын
In question "Subarray with given sum" 4 5 would *also* be an answer .
@pritishpattnaik46743 жыл бұрын
same bro
@pritishpattnaik46743 жыл бұрын
u have missed the break statement after updating st with i+1 and en with j+1
@akshatvyas25943 жыл бұрын
@@pritishpattnaik4674 right 👍
@the3idiots7873 жыл бұрын
do anyone try this code on gfg .its not passing all the test case . is it happening with me only
@hrithikgupta94693 жыл бұрын
Sir please tell me how you think suitable time complexity of the this program using constrains.
@mbillah0-teched2 жыл бұрын
Find a continuous subarray which adds to a given number S. If there are multiple such subarrays which one should we consider? Like in 1 2 3 7 5 array: Two subarray (2 3 7=12 and 7 5=12) has the sum=S. For those ans are [2,4] and [4,5]. Which one will be considered as right ans?
@accepted58563 жыл бұрын
Please show how can we further optimize the question 'First Missing Positive Integer' in O(1) space
@gauravjaiswal74073 жыл бұрын
is some of the questions, explanations were not clear !!!!!!!!!
@piushpaul48803 жыл бұрын
Watch it in slow speed....don't expect yourself to understand it in once .
@rajveerrathod11823 жыл бұрын
explanation is far better then anyother course plz do cooperate and do nt make comment like this
@swarnamitra25423 жыл бұрын
Thanx a lot . great teaching but one request can u make some more videos on the programms asked by these MNCS during interview plzzz😊😊😊
@prajapatishyamdineshkumar44562 жыл бұрын
I think this one is easier for last qs. #include using namespace std; int main(){ int n; cin>>n; int arr[n]; for(int i=0;i>arr[i]; }int min=0,j=0; int flag=0; while(j=5){ cout
@MohdIrshad-kt7ft3 жыл бұрын
Waise mai isi saal DTU me admission lene wala hu lekin phir bhi mujhe coding me interest ki wajah se mai ye dekh raha hu. Nice aman bhaiyya
@aritradhabal3 жыл бұрын
Konsa branch bhaiya?
@HelloRana3 жыл бұрын
same bro i am also joining nsut may go to dtu in next round
@MohdIrshad-kt7ft3 жыл бұрын
@@aritradhabal yrr mai outside delhi ka hu mujhe electrical hi mil sakti hai
@MohdIrshad-kt7ft3 жыл бұрын
@@HelloRana aap delhi ke ho ya outside
@HelloRana3 жыл бұрын
@@MohdIrshad-kt7ft delhi
@ravichavda15763 жыл бұрын
In Vs code terminal when we intialize N=1e6 or 1e5. It terminates with exit code 1
@nikhiljha31683 жыл бұрын
same problem
@pandeyshashidhar3 жыл бұрын
int idx[N]; I think in this You have taken n . mine code is running #include #include using namespace std; int main() { int n,mx=-1,j=0 , ans=0; cin>>n; int a[n]; for(int i=0;i>a[i]; } int N = 1e6; int idx[N]; for(int i=0;i
@soumojitchowdhury1512 жыл бұрын
Yes in vscode it doesn't executer after 1e6 part
@shrutibansal-52623 жыл бұрын
And thanku so much bhiya to teach us... Hats off Aman bhiya and his team..
@theyoutuber778 Жыл бұрын
In the first question, the index value from the first array becomes the element in the second array. And the elements in the first array are the index values in the second array.
@alokmishra65713 жыл бұрын
in the first repeating array question what if we have an element as a negative number
@bosesj2 жыл бұрын
there ll not be in this case, see the constraints
@varunsingh99992 жыл бұрын
index wale array me INT_MIN se intialise krna pdega shyd ( for loop ke andr )
@frekinshorts42373 жыл бұрын
Where did min(mindind , idx[a[i]]); Please explain the use of this function 🙏
@mehboobahmed8923 жыл бұрын
It is like 2 = Min(2,6) Here min is function in c++ which returns smaller value between..(2,6)
@Explore_with_anish3 жыл бұрын
it will compare the index of repeating number and update minindx.
@keshavbajaj30553 жыл бұрын
tActually this below code was sufficient for sum of subarray problem while(js) { sum -=arr[i]; i++; } if(sum==s) { start=i+1; end=j+1; break; } j++; }
@piyushmusaddi12723 жыл бұрын
Thank you so much sir, never thoughts of any of such approach while solving codes