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

แชร์
ฝัง
  • เผยแพร่เมื่อ 5 ส.ค. 2024
  • 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)

ความคิดเห็น • 508

  • @takeUforward
    @takeUforward  ปีที่แล้ว +100

    Let's march ahead, and create an unmatchable DSA course! ❤
    Use the problem links in the description.

    • @Vijaykrishnan2000
      @Vijaykrishnan2000 ปีที่แล้ว +2

      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 ปีที่แล้ว +1

      @@PHANTOMWORLD the given array is sorted. No need to sort it.

    • @itsmrcrazy7670
      @itsmrcrazy7670 ปีที่แล้ว

      @@Vijaykrishnan2000 bro have you found soloution for this

  • @ariobotgaming
    @ariobotgaming หลายเดือนก่อน +39

    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 24 วันที่ผ่านมา +1

      Agreed 💯

    • @karthik-varma-1579
      @karthik-varma-1579 2 วันที่ผ่านมา

      The Striver Approach is good for learning process and it will be helpful to think for good solution...
      but in interview's they expect us to solve the problem(in less time constraint ) so we explain the Better Approach and we Optmize it to Optimal Approach to interviewer and directly jump into the optimal code. so this is good pathway we should follow in the interview.
      SO ask the interviewer for time given to solve this solution . Mostly Try to jump into the direct optimal solution.

  • @Akash-yr2if
    @Akash-yr2if ปีที่แล้ว +23

    Striver shouting top oof voice and these DSA problems are getting slightly one after the other in my head. Thanks Striver

  • @sharathkumar8338
    @sharathkumar8338 ปีที่แล้ว +159

    are you planning to put Scaler Academy out of business.?? 😆😆

    • @shubhamKumar-mb6he
      @shubhamKumar-mb6he 3 หลายเดือนก่อน +8

      Bhai matt has itna daant bahar nikal jayega

    • @abhishekg2766
      @abhishekg2766 หลายเดือนก่อน +2

      Bruhhh they take training from him lamo

  • @ParasSharma-mf8or
    @ParasSharma-mf8or ปีที่แล้ว +59

    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 หลายเดือนก่อน +1

      0:11 motivation 😅 required too

  • @actuallynxiss
    @actuallynxiss ปีที่แล้ว +20

    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 ปีที่แล้ว +4

    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!

  • @merlingrace6850
    @merlingrace6850 9 หลายเดือนก่อน +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

  • @AarzooBansal
    @AarzooBansal หลายเดือนก่อน

    Thank you for all your videos! You have no idea how much these are helping everyone out there!!

  • @helloworld2054
    @helloworld2054 ปีที่แล้ว +4

    Understood everything, you are one of a kind Striver!

  • @tabrezahmed1000
    @tabrezahmed1000 11 หลายเดือนก่อน +5

    Corrected code for missing numbers:
    class Solution {
    public:
    int missingNumber(vector& nums) {
    for(int i = 1; i

  • @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

  • @Deena_Bandhu
    @Deena_Bandhu ปีที่แล้ว +6

    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

  • @pranavrakhunde
    @pranavrakhunde 11 หลายเดือนก่อน +5

    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 หลายเดือนก่อน +1

      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

  • @cinime
    @cinime ปีที่แล้ว +2

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

  • @rahulkathayat8542
    @rahulkathayat8542 ปีที่แล้ว +7

    Love your content striver keep blessing us with such amazing videos

  • @Josuke217
    @Josuke217 26 วันที่ผ่านมา

    Extraordinary way of teaching. I never thought I would be able to solve all these questions quickly. Thanks man

  • @GB-su9gu
    @GB-su9gu ปีที่แล้ว +9

    you are real hero for me.
    best teacher
    like done 😊

  • @shubhamagarwal1434
    @shubhamagarwal1434 วันที่ผ่านมา

    #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....

  • @055_meetmakwana9
    @055_meetmakwana9 5 หลายเดือนก่อน +3

    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.

  • @PrithaMajumder
    @PrithaMajumder 2 หลายเดือนก่อน +1

    Raj, Thanks a lot for This Amazing Video about C++ Arrays
    Video - 3 Completed ✅

  • @john_doe_2231
    @john_doe_2231 ปีที่แล้ว +16

    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 .

  • @Viratrohit184
    @Viratrohit184 ปีที่แล้ว +2

    Thankyou striver for your hardwork to make me understand your efforts make me work hard

  • @aashishas7044
    @aashishas7044 11 หลายเดือนก่อน

    The video and material were awesome. thanks for your efforts.

  • @jishnuraj2278
    @jishnuraj2278 ปีที่แล้ว +1

    Understood! Amazing Explanation!

  • @AJDJ108
    @AJDJ108 10 หลายเดือนก่อน

    Understood each concept brother we need this kind of video 🎉

  • @itzmartin20
    @itzmartin20 11 หลายเดือนก่อน

    Understood! You make my day again brother!

  • @saikrishnaganguri
    @saikrishnaganguri ปีที่แล้ว +1

    Understood, Thank you so much for the awesome content..

  • @dhruvsolanki4473
    @dhruvsolanki4473 ปีที่แล้ว +1

    Super amazing videos and explanations.

  • @himadriroy7980
    @himadriroy7980 9 หลายเดือนก่อน

    Understood!! Loved the lecture.

  • @virendrakumarmishra876
    @virendrakumarmishra876 ปีที่แล้ว

    amazing just loved it
    so clear explanation 😍

  • @user-fn1lx2gv9j
    @user-fn1lx2gv9j ปีที่แล้ว +17

    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];
    }

  • @meghasharma4875
    @meghasharma4875 3 ชั่วโมงที่ผ่านมา

    i doing this first time and but in my mind i directly hit optimal solution , thanks striver also ,and after complete some video its develop new thinking way to approach problems

  • @Ishantkumar-cr6ug
    @Ishantkumar-cr6ug ปีที่แล้ว +1

    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 ปีที่แล้ว +1

    Thanks for the amazing content striver

  • @ABCDEFGH-fz5ju
    @ABCDEFGH-fz5ju 3 หลายเดือนก่อน

    His actions while explaining problems are just killer😎

  • @konankikeerthi
    @konankikeerthi 2 หลายเดือนก่อน

    Thank you bro. i got clear understanding. i understood it very well

  • @shanmugapriya6735
    @shanmugapriya6735 ปีที่แล้ว

    You are my lifesaver thank you so much sir

  • @utsavseth6573
    @utsavseth6573 ปีที่แล้ว

    Lovely Work Raj.

  • @SudhanshuPanthri
    @SudhanshuPanthri ปีที่แล้ว

    Brilliantly Explained Bhaiya.

  • @rish7394
    @rish7394 ปีที่แล้ว +1

    Bhaiya kasam se din se so rkha tha🥲, abhi socha kya kru notification aagya thanks.

  • @kavyabanka4482
    @kavyabanka4482 ปีที่แล้ว

    Thanks for this amazing video

  • @bitlegion1027
    @bitlegion1027 10 หลายเดือนก่อน

    understood bhaiyaaa thankyou for the great explaination

  • @monimoni6760
    @monimoni6760 ปีที่แล้ว +2

    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.

  • @vishal_s583
    @vishal_s583 ปีที่แล้ว

    Great work ❤️

  • @sukhpreetsingh5200
    @sukhpreetsingh5200 ปีที่แล้ว

    As usual awesome ❤

  • @praveentiwari629
    @praveentiwari629 10 หลายเดือนก่อน

    AWESOME EXPLANATION

  • @suheabkhan2546
    @suheabkhan2546 ปีที่แล้ว

    Loved the content

  • @rohitprasad5708
    @rohitprasad5708 ปีที่แล้ว +7

    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 ปีที่แล้ว +1

      You can watch this detailed Java collections tutorial: th-cam.com/video/VE_AAUxTUCY/w-d-xo.html&ab_channel=RiddhiDutta

  • @aliakbaransaria3-925
    @aliakbaransaria3-925 11 หลายเดือนก่อน

    Very good explanation

  • @shivangisirohi6032
    @shivangisirohi6032 8 หลายเดือนก่อน

    great explanation sir

  • @themusicguy539
    @themusicguy539 ปีที่แล้ว +2

    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)

  • @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?

  • @Ramsiya658
    @Ramsiya658 ปีที่แล้ว

    Understood striver much love to you

  • @sohamchikane6591
    @sohamchikane6591 11 หลายเดือนก่อน +1

    gaining confidence day by day one question though when should we revise?
    any suggestions would be appreciated.

  • @gouravupadhyay9092
    @gouravupadhyay9092 10 หลายเดือนก่อน

    Understood, thankyou bhaiya

  • @hareshnayak7302
    @hareshnayak7302 4 หลายเดือนก่อน

    Understood, thanks striver.

  • @peddikarthik7832
    @peddikarthik7832 ปีที่แล้ว +1

    one slight correction at 17:23 : xor can exceed largest number.(ie when number n%4==2)

  • @sarangkumarsingh7901
    @sarangkumarsingh7901 5 หลายเดือนก่อน

    Awesome Sir.............

  • @DeveloperRB
    @DeveloperRB 9 หลายเดือนก่อน

    Great stuff ❤❤

  • @khushil9988
    @khushil9988 8 หลายเดือนก่อน

    understood
    and yes we need the video

  • @DevashishJose
    @DevashishJose ปีที่แล้ว

    Understood, Thank you

  • @Mythri333
    @Mythri333 6 หลายเดือนก่อน

    Thank you so much 😊

  • @shorts_shots514
    @shorts_shots514 ปีที่แล้ว

    understood !!! thank you

  • @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?

  • @Raj10185
    @Raj10185 ปีที่แล้ว

    Understood everything Striver :)

  • @shreyanshsharma7906
    @shreyanshsharma7906 ปีที่แล้ว

    understood thanks raj bhai

  • @_hulk748
    @_hulk748 ปีที่แล้ว

    Understood sir❤🙇‍♂️🙏

  • @winter_hope_
    @winter_hope_ 5 วันที่ผ่านมา

    Love you sir understood

  • @faysalmahmud2721
    @faysalmahmud2721 ปีที่แล้ว

    best explaination

  • @Hipfire786
    @Hipfire786 4 หลายเดือนก่อน

    understood everything sir

  • @lifehustlers164
    @lifehustlers164 10 หลายเดือนก่อน +1

    Completed 3/28!!!

  • @RaviKumar-sn6tu
    @RaviKumar-sn6tu 5 หลายเดือนก่อน

    sir you have my heart
    😇

  • @divyaagarwal3563
    @divyaagarwal3563 ปีที่แล้ว

    UNDERSTOOD!

  • @user-gl8mv6dg4t
    @user-gl8mv6dg4t 21 วันที่ผ่านมา

    maza aa gaya .❤

  • @foreverabel7680
    @foreverabel7680 11 หลายเดือนก่อน

    understood sir 🙌

  • @ankushladani496
    @ankushladani496 ปีที่แล้ว

    Understood
    More videos....🎉

  • @AniketSingh-gm9nh
    @AniketSingh-gm9nh 12 วันที่ผ่านมา

    understood bhaiyaa🙂

  • @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]?

  • @fallenAngel-cw9ki
    @fallenAngel-cw9ki ปีที่แล้ว

    understood, ty!!

  • @pujyamvssnkdheeraj5069
    @pujyamvssnkdheeraj5069 10 หลายเดือนก่อน +1

    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 )

  • @ajaywankhade5054
    @ajaywankhade5054 3 หลายเดือนก่อน

    Thank you

  • @indroneelgoswami5654
    @indroneelgoswami5654 11 วันที่ผ่านมา

    UNDERSTOOD!!

  • @shashank_0807
    @shashank_0807 3 หลายเดือนก่อน

    Whenever your heart is broken
    Don't ever forget you're golden ❤✨
    The happiness when you hear these lines at the end of each video >>>>>>>>>>>>>>>>>> ♾

  • @NIRI0242
    @NIRI0242 14 วันที่ผ่านมา

    If you ever feel so broken dont ever forget you re golden, i will find the light in you.❤❤❤

  • @Sanjana-gp3gn
    @Sanjana-gp3gn ปีที่แล้ว

    Understood bhaiya ❤

  • @sahilranjan324
    @sahilranjan324 ปีที่แล้ว

    Bhaiyaa Thanks 😊👍

  • @per.seus._
    @per.seus._ ปีที่แล้ว +1

    understood💯❤

  • @abdulbasit9585
    @abdulbasit9585 14 วันที่ผ่านมา

    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?

  • @Miracle_shaw
    @Miracle_shaw ปีที่แล้ว

    thank you

  • @karnifex7606
    @karnifex7606 ปีที่แล้ว

    missing number with one variable(more simplified)
    int res = N;
    for(int i=0; i

  • @santoshmore2953
    @santoshmore2953 ปีที่แล้ว

    hey can i use the same logic to code in JAVASCRIPT? since i am doing DSA in JAVASCRIPT.

  • @heyOrca2711
    @heyOrca2711 4 หลายเดือนก่อน

    Understood sir!

  • @user-tk2vg5jt3l
    @user-tk2vg5jt3l 6 หลายเดือนก่อน

    Thank you Bhaiya

  • @shubhamchattree900
    @shubhamchattree900 ปีที่แล้ว

    Sir which ide are you using ok please can you tell ????

  • @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 😊

  • @yashwanthbm7543
    @yashwanthbm7543 ปีที่แล้ว

    THANKS BRO

  • @YourCodeVerse
    @YourCodeVerse 10 หลายเดือนก่อน

    Understood✅🔥🔥

  • @amanallrounder2092
    @amanallrounder2092 หลายเดือนก่อน

    1st optimal solution was really good and new for me 09:00