Тёмный

Find element that appears once | Find missing number | Max Consecutive number of 1's | Arrays Part-3 

take U forward
Подписаться 623 тыс.
Просмотров 302 тыс.
50% 1

Notes/C++/Java/Python codes in Step 3.1 of bit.ly/tufA2ZYt
Find the missing number: takeuforward.org/arrays/find-...
Maximum Consecutive Ones: takeuforward.org/data-structu...
Find the number that appears once, and the other numbers twice: takeuforward.org/arrays/find-...
Problem links.
Find the missing number: bit.ly/3ZdwAkN
Maximum Consecutive Ones: bit.ly/3ZFZji5
Find the number that appears once, and the other numbers twice: bit.ly/3VOlEHp
We have solved the above problems, and we have gone from brute force and ended with the most optimal solution.
Full Course: bit.ly/tufA2ZYt
You can follow me across social media, all my handles are below:
Linkedin/Instagram/Telegram: linktr.ee/takeUforward
0:00 Introduction of course
0:57 Missing Number
18:16 Code-compiler (Missing Number)
18:44 Maximum Consecutive number of 1's
21:06 Code-compiler (Maximum Consecutive number of 1's)
22:49 Find the number that appear once and other number twice
36:40 Code-compiler (Find the number that appear once and other number twice)

Опубликовано:

 

28 июл 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 498   
@takeUforward
@takeUforward Год назад
Let's march ahead, and create an unmatchable DSA course! ❤ Use the problem links in the description.
@Vijaykrishnan2000
@Vijaykrishnan2000 Год назад
Find the number that appear once and other number twice : (Partially Accepted) needed binary search approach ?
@ayushsaurav38
@ayushsaurav38 Год назад
bro u use map in array series and in course series so atleast give a short intro of whatever u r using the course bcz this course is for beginners as u said
@PHANTOMWORLD
@PHANTOMWORLD Год назад
@@Vijaykrishnan2000 binary search requires sorting and sorting takes O(nlogn) so how it is more optimal ?
@subrajeetmaharana
@subrajeetmaharana Год назад
@@PHANTOMWORLD the given array is sorted. No need to sort it.
@itsmrcrazy7670
@itsmrcrazy7670 Год назад
@@Vijaykrishnan2000 bro have you found soloution for this
@ariobotgaming
@ariobotgaming Месяц назад
In an interview, I personally feel jumping to "better" solution is good, instead of "brute" solution, if "better" exists that is. Reasons: - I dont think the time constraint allows for us to cycle through all three(brute, better, optimal) in 45min-1hr time window (usually 2-3 questions can be asked). - Also brute are confusing at times, as it mostly involves combining many steps at times and the dry run will take time, so will the psuedo code. - We must also account the stress of the interview, I don't think I can come up with different version of solutions for a single question without messing up the flow (which might ruin the concentration and cause panic). So I think its better to give a solution that you know it works for sure.
@Josuke217
@Josuke217 16 дней назад
Agreed 💯
@sharathkumar8338
@sharathkumar8338 Год назад
are you planning to put Scaler Academy out of business.?? 😆😆
@shubhamKumar-mb6he
@shubhamKumar-mb6he 3 месяца назад
Bhai matt has itna daant bahar nikal jayega
@abhishekg2766
@abhishekg2766 Месяц назад
Bruhhh they take training from him lamo
@Akash-yr2if
@Akash-yr2if Год назад
Striver shouting top oof voice and these DSA problems are getting slightly one after the other in my head. Thanks Striver
@actuallynxiss
@actuallynxiss Год назад
I absolutely love your videos man! I understood everything very well. Internship season is gonna start very soon in my college and this helps me a ton!
@reki7247
@reki7247 Год назад
you're the best, man! hats off to you for great teaching and concepts that you elaborate so smoothly, i'm second year btech student and i am so thankful to have found you! ever since you came to my college for techtalk i've been motivated and a fan of yours, keep up the good work!
@helloworld2054
@helloworld2054 Год назад
Understood everything, you are one of a kind Striver!
@rahulkathayat8542
@rahulkathayat8542 Год назад
Love your content striver keep blessing us with such amazing videos
@cinime
@cinime Год назад
Understood! Amazing explanation as always, thank you very much for your effort!!
@AarzooBansal
@AarzooBansal Месяц назад
Thank you for all your videos! You have no idea how much these are helping everyone out there!!
@ParasSharma-mf8or
@ParasSharma-mf8or Год назад
0:00 Introduction of course 0:57 Missing Number 18:16 Code-compiler (Missing Number) 18:44 Maximum Consecutive number of 1's 21:06 Code-compiler (Maximum Consecutive number of 1's) 22:49 Find the number that appear once and other number twice 36:40 Code-compiler (Find the number that appear once and other number twice) Please please please maintain consistency it's a humble request from the bottom of my heart 🙏🙏.
@alwayshemanthreddy
@alwayshemanthreddy 5 месяцев назад
0:11 motivation 😅 required too
@Deena_Bandhu
@Deena_Bandhu Год назад
bhaiya its mean a lot for us who can't afford a course...! and providing this level of lectures such a next level....! i will try to be a like you in future so i can help the peoples in other way....! thank you bhaiyya
@gwatsinthong3180
@gwatsinthong3180 5 месяцев назад
Thank you Sir 🙏 Truly the way you explain is really easy to understand. It is hard to believe such a great man exist that gives such great quality material for free
@merlingrace6850
@merlingrace6850 9 месяцев назад
You did a great job.... I used to afraid of dsa at first but the day I find your channel, I'll be more confident now to clear dsa rounds . Your hard work deserves a lot Striver. You explanation is crystal clear and it's keep us engaging with each step of concept.
@user-oi1oe5he5r
@user-oi1oe5he5r 5 месяцев назад
we learn concept but forget again ,bcs there are lots of problems and concepts
@GB-su9gu
@GB-su9gu Год назад
you are real hero for me. best teacher like done 😊
@john_doe_2231
@john_doe_2231 Год назад
Hey Striver , i had a question since you're working in Europe.Do European tech companies also ask a lot of DSA in their interviews or is it more focused towards other topics like design ,LLD etc ? Would really love a video on this .
@055_meetmakwana9
@055_meetmakwana9 5 месяцев назад
Absolutly loved it, for the first problem in this video, I actually tried to solve it on my own, and thought of an solution which turns out to be a optimal solution you metioned here in this video, this is not a small achievement for me😃. Thank you striver.
@aashishas7044
@aashishas7044 11 месяцев назад
The video and material were awesome. thanks for your efforts.
@pranavrakhunde
@pranavrakhunde 10 месяцев назад
For the last problem Find number that appear once and other twice the below code passes all the 11 test cases int getSingleElement(vector &arr){ int ans = 0; for(int i=1;i
@user-oi1oe5he5r
@user-oi1oe5he5r 5 месяцев назад
nice
@rudrsharma4758
@rudrsharma4758 2 месяца назад
that solution is wrong, it won't give correct output for cases like [0, 1, 0, 1, 2] in this case at the first iteration for i=1: arr[1-1] != arr[1] is true and thus it will return arr[1-1] as output, which is 0, whereas the correct output is clearly 2.
@user-kk2pk2cd9c
@user-kk2pk2cd9c 2 месяца назад
@@rudrsharma4758 It is sorted array though.
@akshitrajputhere
@akshitrajputhere Месяц назад
Thanks mate this does work
@Viratrohit184
@Viratrohit184 11 месяцев назад
Thankyou striver for your hardwork to make me understand your efforts make me work hard
@Josuke217
@Josuke217 18 дней назад
Extraordinary way of teaching. I never thought I would be able to solve all these questions quickly. Thanks man
@jishnuraj2278
@jishnuraj2278 Год назад
Understood! Amazing Explanation!
@virendrakumarmishra876
@virendrakumarmishra876 Год назад
amazing just loved it so clear explanation 😍
@PrithaMajumder
@PrithaMajumder 2 месяца назад
Raj, Thanks a lot for This Amazing Video about C++ Arrays Video - 3 Completed ✅
@itzmartin20
@itzmartin20 11 месяцев назад
Understood! You make my day again brother!
@saikrishnaganguri
@saikrishnaganguri Год назад
Understood, Thank you so much for the awesome content..
@dhruvsolanki4473
@dhruvsolanki4473 Год назад
Super amazing videos and explanations.
@AJDJ108
@AJDJ108 9 месяцев назад
Understood each concept brother we need this kind of video 🎉
@himadriroy7980
@himadriroy7980 8 месяцев назад
Understood!! Loved the lecture.
@Ishantkumar-cr6ug
@Ishantkumar-cr6ug Год назад
understood bhaiya...we need more videoes in a week, and get well soon..
@habeeblaimusa4466
@habeeblaimusa4466 Год назад
Thanks for this amazing video..God bless you
@varunvarun5723
@varunvarun5723 Год назад
Thanks for the amazing content striver
@monimoni6760
@monimoni6760 Год назад
Hi Striver, Thanks for your effort.When will you be covering strings and Heap.I am not able to see any video related to that topic in your channel.
@themusicguy539
@themusicguy539 Год назад
Hello sir Thankyou for your efforts I have a question sometimes I make the approach of a question but not able to code it...maybe lack of doing questions by myself But just when I was doing questions of binary search of rotated sorted array of your DSA sheet...I am neither able to make approach nor code it....any guidance... (4th semester student)
@user-fn1lx2gv9j
@user-fn1lx2gv9j Год назад
As the input array is already sorted, we can use binary search to find the single element in the array. public int singleNonDuplicate(int[] nums) { int low = 0; int high = nums.length - 1; int mid; while (low < high) { mid = (low + high) / 2; if (mid % 2 != 0) { mid -= 1; } if (nums[mid] == nums[mid + 1]) { low = mid + 2; } else { high = mid; } } return nums[low]; }
@shanmugapriya6735
@shanmugapriya6735 Год назад
You are my lifesaver thank you so much sir
@tabrezahmed1000
@tabrezahmed1000 11 месяцев назад
Corrected code for missing numbers: class Solution { public: int missingNumber(vector& nums) { for(int i = 1; i
@konankikeerthi
@konankikeerthi Месяц назад
Thank you bro. i got clear understanding. i understood it very well
@ABCDEFGH-fz5ju
@ABCDEFGH-fz5ju 3 месяца назад
His actions while explaining problems are just killer😎
@utsavseth6573
@utsavseth6573 Год назад
Lovely Work Raj.
@SudhanshuPanthri
@SudhanshuPanthri Год назад
Brilliantly Explained Bhaiya.
@kavyabanka4482
@kavyabanka4482 Год назад
Thanks for this amazing video
@bitlegion1027
@bitlegion1027 10 месяцев назад
understood bhaiyaaa thankyou for the great explaination
@sohamchikane6591
@sohamchikane6591 11 месяцев назад
gaining confidence day by day one question though when should we revise? any suggestions would be appreciated.
@peddikarthik7832
@peddikarthik7832 Год назад
one slight correction at 17:23 : xor can exceed largest number.(ie when number n%4==2)
@vishal_s583
@vishal_s583 Год назад
Great work ❤️
@sukhpreetsingh5200
@sukhpreetsingh5200 Год назад
As usual awesome ❤
@santoshmore2953
@santoshmore2953 Год назад
hey can i use the same logic to code in JAVASCRIPT? since i am doing DSA in JAVASCRIPT.
@rish7394
@rish7394 Год назад
Bhaiya kasam se din se so rkha tha🥲, abhi socha kya kru notification aagya thanks.
@aliakbaransaria3-925
@aliakbaransaria3-925 11 месяцев назад
Very good explanation
@jashanuppal9678
@jashanuppal9678 5 месяцев назад
@takeUfoward I had one doubt, in missing number like what if the the last number is missing then the XOR logic will not work because it nums.size will itself be 1 less already so it will not work that case?
@praveentiwari629
@praveentiwari629 10 месяцев назад
AWESOME EXPLANATION
@suheabkhan2546
@suheabkhan2546 Год назад
Loved the content
@sysybaba420
@sysybaba420 6 месяцев назад
@26:50, why do you need a for loop to look for the largest element? the input array is already sorted so the last element will always be the largest no?
@gouravupadhyay9092
@gouravupadhyay9092 9 месяцев назад
Understood, thankyou bhaiya
@shivangisirohi6032
@shivangisirohi6032 7 месяцев назад
great explanation sir
@shubhamchattree900
@shubhamchattree900 Год назад
Sir which ide are you using ok please can you tell ????
@Ramsiya658
@Ramsiya658 Год назад
Understood striver much love to you
@DSEI-PrashunDash
@DSEI-PrashunDash 11 месяцев назад
If a sorted array is given, then why do i need a for loop to find the max element? Cant i just initialize maxelement = arr[n-1]?
@rohankadam7376
@rohankadam7376 10 месяцев назад
Does any know how to declare a map with fixed size and with default value in c++.
@pujyamvssnkdheeraj5069
@pujyamvssnkdheeraj5069 10 месяцев назад
Bro A small Doubt - In Finding The Number that appears once, you took the max element by using a Loop - TC - O( n ) & a hash iterator - TC- O(n) ,:- TC - O( 3n ) > Insted [ My Logic ] - If Array is Always Sorted can we take array [ n-1] as MAX so tha t we do not need to iterate the Entire hashing we can iterate up to max value we can make it - TC - O( 2n ) & SC - O ( n )
@rohitprasad5708
@rohitprasad5708 Год назад
Bro can you please take some time out from your busy schedule and upload a detailed video on Java collection framework, and can you please let us know what all core skills required for being a Java developer apart from DSA. Thanks
@aadeshputhran7642
@aadeshputhran7642 Год назад
You can watch this detailed Java collections tutorial: ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-VE_AAUxTUCY.html&ab_channel=RiddhiDutta
@DevashishJose
@DevashishJose Год назад
Understood, Thank you
@shorts_shots514
@shorts_shots514 Год назад
understood !!! thank you
@Mythri333
@Mythri333 5 месяцев назад
Thank you so much 😊
@hareshnayak7302
@hareshnayak7302 4 месяца назад
Understood, thanks striver.
@shreyanshsharma7906
@shreyanshsharma7906 Год назад
understood thanks raj bhai
@DeveloperRB
@DeveloperRB 8 месяцев назад
Great stuff ❤❤
@prasanna9440
@prasanna9440 11 месяцев назад
Why there is need of making n=N-1 in missing element problem during optimal approach with xor
@khushil9988
@khushil9988 8 месяцев назад
understood and yes we need the video
@_hulk748
@_hulk748 Год назад
Understood sir❤🙇‍♂️🙏
@jkeryt870
@jkeryt870 3 месяца назад
27:55 why you are implementing a loop initially to find a maximum of a, we can directly find the maximum of a right, can you explain please if anyone know?
@niteshrathore4341
@niteshrathore4341 10 месяцев назад
if we have an array like - [0,1] then the hash array approach will not work ?
@moviesinthelist6551
@moviesinthelist6551 11 месяцев назад
@takeUforward at 16:40, I think even we are running the first statement in second loop to avoid the first loop still the complexity going to be O(2n) because we increase the no. of statement executing
@anshumann
@anshumann 10 месяцев назад
that's not how it works
@moviesinthelist6551
@moviesinthelist6551 10 месяцев назад
@@anshumann ohh I thought every line of code or every task takes one unit of time
@dipingrover1970
@dipingrover1970 4 месяца назад
i have one thought im mind plz let me know if that works using set we can also solve that first we insert elements in the set find its sum and double it let say s then we find sum of all elements of array say sum then we return s-sum very similar to summation approach in missing number ques
@ishaanagarwal2622
@ishaanagarwal2622 11 месяцев назад
hey striver please discuss the solution of the coding ninjas problem of maximum consecutive length there is more to the question and I am not able to understand the approach the solution given in the discuss section, neither can I understand the approach given in chatgpt
@dineshs2484
@dineshs2484 4 месяца назад
Can we do like, if index number +1 = current element in the array.if true then increase index . Or return variable we are using to check..is it good ???
@mehrasmotivation6970
@mehrasmotivation6970 Год назад
Thank you bhaiya SDE sheet ke questions karane ke liye
@sarangkumarsingh7901
@sarangkumarsingh7901 4 месяца назад
Awesome Sir.............
@Raj10185
@Raj10185 Год назад
Understood everything Striver :)
@abdulbasit9585
@abdulbasit9585 6 дней назад
For the last problem's hashing approach why iterate through the given array to check their occurrence in hash array when you can just iterate through the hash array to check if hash[ i ] == 1 or not and then return i?
@Hipfire786
@Hipfire786 3 месяца назад
understood everything sir
@faysalmahmud2721
@faysalmahmud2721 Год назад
best explaination
@garimaarora5311
@garimaarora5311 Год назад
since here in the last question (find element which occurs once), it should not be recommended to use unordered_maps whose worst case time complexity could be O(N) resulting in O(N^2), so my question is how to identify when to use ordered maps or when to use unordered maps?
@ShivamTh405
@ShivamTh405 Год назад
I think worst case of unordered_map happens rarely because test cases are not set that way. Only few leetcode questions have test cases that fails while using unordered_map.
@ajaywankhade5054
@ajaywankhade5054 2 месяца назад
Thank you
@aadeshputhran7642
@aadeshputhran7642 Год назад
For the number that appears once problem, if the input array is sorted, I think the optimal time complexity will be O(log n) using binary search.
@takeUforward
@takeUforward Год назад
Yes if it is sorted, here it was not
@user-ll9py8pq2u
@user-ll9py8pq2u 7 месяцев назад
how can i solve this question using binary search
@jaydeeppatil7936
@jaydeeppatil7936 6 месяцев назад
@@user-ll9py8pq2u did you manage to solve it using binary search
@foreverabel7680
@foreverabel7680 11 месяцев назад
understood sir 🙌
@Miracle_shaw
@Miracle_shaw Год назад
thank you
@impalash_ag
@impalash_ag 2 месяца назад
Hi @takeUforward, 2 questions on Missing Number problem: 1- Does the Brute Force solution has to be same as yours? For instance, I thought of sorting the array first and then check each element with index+1, and as soon as we find the missing element we return with index+1. The TC of the overall algorithm will be 0(nlogn){for sorting} + 0(n){for traversing} 2- What if we can't think of any better solution and miss explaining that to an interviewer? For instance, in my case I could think of the above and summation of n natural numbers solutions only. I hope you address the questions and reply, thank you 😊
@fallenAngel-cw9ki
@fallenAngel-cw9ki Год назад
understood, ty!!
@user-tk2vg5jt3l
@user-tk2vg5jt3l 5 месяцев назад
Thank you Bhaiya
@ItsHarsh18
@ItsHarsh18 5 месяцев назад
Hey in missing number cant v do this will sort the array and then will take a single loop and will match the if(i != arr[i]) and if not the case will return the I and at last will return the arr.length (to tackle the edge case of [0,2] )
@ankushladani496
@ankushladani496 Год назад
Understood More videos....🎉
@ItsAbhiDestiny
@ItsAbhiDestiny Месяц назад
Bhaiya XOR approach and brute force approach only works for sorted array
@sahilranjan324
@sahilranjan324 Год назад
Bhaiyaa Thanks 😊👍
@divyaagarwal3563
@divyaagarwal3563 Год назад
UNDERSTOOD!
@AniketSingh-gm9nh
@AniketSingh-gm9nh 4 дня назад
understood bhaiyaa🙂
@nsabhiram7440
@nsabhiram7440 9 месяцев назад
What happens if I can directly give the better or optimal solution, because, I'm not used to brute force solution.
@abusyed6121
@abusyed6121 5 месяцев назад
Is this works bhiya if we are having more than one element missing in an array
@Sanjana-gp3gn
@Sanjana-gp3gn Год назад
Understood bhaiya ❤
Далее
The moment we stopped understanding AI [AlexNet]
17:38
Просмотров 794 тыс.
Поём вместе с CLEXXD🥵 | WICSUR #shorts
01:00
These Roblox Players Just Got Their PC's Hacked...
10:38
Germany | Can you solve this ? | Math Olympiad  (x,y)=?
11:02
I gave 127 interviews. Top 5 Algorithms they asked me.
8:36