Single Number II II 4 -Methods II Bit Manipulation II Leetcode 137 II C++/Java/Python

Sdílet
Vložit
  • čas přidán 27. 07. 2024
  • In this video, I'll talk about how to solve Leetcode 137. Single Number II II Bit Manipulation II Pattern Recognition
    Checkout DSA-169 Series: • Aryan DSA-169 Series |...
    Problem Link: leetcode.com/problems/single-...
    Code & Notes: drive.google.com/file/d/1-f0X...
    Let's Connect:
    📝Linkedin: / aryan-mittal-0077
    📸 Instagram: / aryan_mittal_007
    📱Telegram : t.me/aryan_mittal_group
    🤖 Github: github.com/aryan-0077
    🛍️ Products I use in Videos: (✨ Marked for Mostly requested Products)
    Main Camera (Canon 200D ii): amzn.to/41cfS5h
    Vlog Camera (iphone 13): amzn.to/42aOJRh
    Tripod for Lectures: amzn.to/3HMoloF
    Tripod for Vlogs: amzn.to/44wGL6L
    ✨Mic: amzn.to/41bj8gU
    Shadow Multi Colour Light: amzn.to/41bmIrq
    Main Light: amzn.to/3LF6BNb
    Tripod for Lights: amzn.to/3LFcQAt
    Softbox for Lights: amzn.to/42mHqWE
    ✨My Pen Tablet for Notes: amzn.to/44A61ZJ
    ✨New Tablet for Notes: amzn.to/44BjTDa
    Tablet Stand: amzn.to/3NMFIJR
    Power Bank: amzn.to/421yHsZ
    ✨USB Hub: amzn.to/3p8NGTf
    ✨HardDisk to store Lectures: amzn.to/3HKafEs
    ✨My Laptop: amzn.to/44w12ct
    ✨My Monitor: amzn.to/3LCG6YL
    My UPS: amzn.to/3Lydy2y
    My UPS old: amzn.to/3LXT0C3
    ✨My Mouse: amzn.to/3LYmJdY
    ✨My Keyboard: amzn.to/3NJs4ah
    Resources you can try:
    Learn Coding: • Complete RoadMap for C...
    🎥Channel Playlists
    🎥 Baap Graph Series - by Aryan: • Baap Graph Series - by...
    🎥Dynamic Programming: • Complete Dynamic Progr...
    🎥Bit Manipulation: • Complete BIT MANIPULAT...
    🎥Mathematics for DSA: • Complete Mathematics f...
    🎥Leetcode Top Interview Questions: • FAANG & Leetcode Inter...
    🎥Codeforces Problem B Ladder: • Complete PROBLEM B LAD...
    🎥Codeforces Problem C Ladder: • Codeforces PROBLEM C L...
    🎥Codeforces Problem D Ladder: • Complete PROBLEM D LAD...
    🎥 Top 150 Interview Questions: • Top 150 Interview Ques...
    🎥 Complete Array Problem Playlist: • Complete Array Intuit...
    🎥 Complete Binary Search Problem Playlist: • Complete Binary Search...
    🎥 Complete Stack Playlist: • Complete Stack & Queue...
    🎥 Complete Graph Problem Playlist: • Complete Graph Intuiti...
    🎥 Complete TREE Playlist: • Complete TREE Intuitio...
    🎥 Complete DP Problem Solving: • Complete DP Intuition ...
    🎥 Complete Linked List: • Complete Linked List I...
    🎥 Complete Greedy Problem Playlist: • Complete Greedy Intui...
    🎥 Complete Divide & Conquer Algorithm Playlist: • Complete Divide & Conq...
    🎥 Complete Trie Playlist: • Complete Trie Intuitio...
    🎥 Complete Mathematics & Number Theory Problems: • Complete Mathematics &...
    About Channel:
    We teach about how you can grow in life & educate about programming in Fun & Intuitional way.
    About Me:
    I am Aryan Mittal - a Software Engineer, Speaker, Creator & Educator. During my free time, I create programming education content on this channel & also how to use that to grow :)
    ✨ Timelines✨
    0:00 - Bakwas
    1:00 - Problem Explanation
    1:46 - Approach 1
    2:48 - Approach 2 (Intuition + Logic)
    7:48 - Approach 3 (Intuition + Logic)
    12:10 - Approach 3 (Code)
    18:20 - Approach 4 (Building Up)
    23:00 - Approach 4 (Intuition +Logic )
    35:00 - Approach 4 (Code)
    ✨ Hashtags ✨
    #programming #Interviews #leetcode #faang #maang #datastructures #algorithms

Komentáře • 50

  • @ARYANMITTAL
    @ARYANMITTAL  Před rokem +13

    Don't know what Leetcode smoked before placing this question in a Medium Category 🥵!!
    Checkout DSA-169 Series: czcams.com/video/5BuKVS-Vnws/video.html
    Problem Link: leetcode.com/problems/single-number-ii/description/
    Code & Notes: drive.google.com/file/d/1-f0XzUitIZ-U0ieKkomuyK_xUhulAttG/view?usp=sharing

  • @gouthamp9066
    @gouthamp9066 Před rokem +6

    One of the best best CZcamsr who can explain any hard problem easy thanky Aryan we will remember you for ever because your making our lives better

  • @shreyanshthakur5405
    @shreyanshthakur5405 Před rokem +3

    After looking Leetcode solutions section and not understanding the intuition behind the bit manipulation approach, I came here and simply got the intuition behind that very easily.
    Thanks a lot for explaining the links and thought process Aryan!!!

  • @sherlockjunior8612
    @sherlockjunior8612 Před rokem +8

    I guess, at 7:44 you mean to check 3*1e4 for N and not 2^31 because the N is the size of the input, not the range of numbers...

  • @raftywate
    @raftywate Před rokem +5

    Thank you, Aryan! It's a beautiful video. Helped me improve my thought process. Glad that I came across your channel.

  • @jamjam3448
    @jamjam3448 Před měsícem

    My favorite man. Thanks, man

  • @santoshprasadyadav2198
    @santoshprasadyadav2198 Před měsícem

    Loved the way you explained bro, best video for this question i found so far!!

  • @oqant0424
    @oqant0424 Před rokem +1

    beautifully explained.......................the only person on the whole internet who teaches how to build the solution❤❤

  • @bkmeher9005
    @bkmeher9005 Před 5 měsíci

    Great bhai

  • @nikhilbabar2226
    @nikhilbabar2226 Před rokem +2

    Why the solution 3 doesn't work for negative numbers

  • @aftabrahman5863
    @aftabrahman5863 Před 5 měsíci

    great work

  • @shashikiran5385
    @shashikiran5385 Před měsícem

    you're underrated

  • @rishabhgupta9846
    @rishabhgupta9846 Před rokem +1

    Thanks for the video

  • @JihadIsmail
    @JihadIsmail Před rokem

    Thank you so much, I have been looking for the last approach explanation specifically for the last 3 days. Your way of explaining the things and your passion are amazing.

  • @worldfromhome4033
    @worldfromhome4033 Před rokem

    Nice idea of encapsulating the set bits that have come once and twice and then modifying them🔥

  • @midas8003
    @midas8003 Před rokem +1

    Loved the approach bro !

  • @nikeshmali8506
    @nikeshmali8506 Před rokem

    thanks.

  • @nadeking1530
    @nadeking1530 Před rokem

    You earned a sub ! Kudos to your hard work !!!

  • @tejuschaturvedi6234
    @tejuschaturvedi6234 Před rokem

    Mind blowing explanation 💫. The last approach is so amazing . You are very good at this explanatory work . ❤

  • @iWontFakeIt
    @iWontFakeIt Před rokem

    Last approach was ❤

  • @kale-lb5pr
    @kale-lb5pr Před 4 měsíci

    how bit manipulation is taking place pls help im doing dr and run im not getting?

  • @AanganwadiGuriya
    @AanganwadiGuriya Před 10 měsíci

    It was nice one !

  • @kale-lb5pr
    @kale-lb5pr Před 4 měsíci

    i have one question like i was doing dry and run on array [5,5,5,6,4,4,4] after when array element first 4 comes if gtes xor with what ones contains so it technically has 6 bcoz it occured ones then when we xor 6^4 it will not remain 6 pls tell me what im doing wrong something is off i cant pinpoint pls help folks!!

  • @rohanpradhan3160
    @rohanpradhan3160 Před rokem +4

    Loved the approach and how you got to it.. Loved it Thanks......

  • @BiswajitDas-lk7pp
    @BiswajitDas-lk7pp Před 5 měsíci

    Best Explanation but sound is not Clear

  • @a.y_u.s_h
    @a.y_u.s_h Před rokem

    salute

  • @noobplays6673
    @noobplays6673 Před rokem

    class Solution {
    public:
    int singleNumber(vector& nums) {
    int ones=0, twos=0;
    for(int n: nums){
    ones = (ones ^ n) & ~twos; // frequency is 0 and not 2
    twos = (twos ^ n) & ~ones; // frequency is 2 and not 1
    }
    return ones;
    }
    };

  • @arihantjainajbil8182
    @arihantjainajbil8182 Před rokem

    approach 4 is lit

  • @saunaknandi1814
    @saunaknandi1814 Před 11 měsíci

    Aryan can u make complete video dedicated to bit manipulation?

  • @NihalSingh-ld2en
    @NihalSingh-ld2en Před rokem +2

    did you tried to submit your 3rd intution code ? as the number can be negative this intution will not work

    • @nikhilbabar2226
      @nikhilbabar2226 Před rokem

      Yes, it is not working for negative numbers

    • @jayantsahu6792
      @jayantsahu6792 Před rokem

      class Solution {
      public:
      int singleNumber(vector& nums) {
      int n = nums.size(), ans = 0;
      for (int i = 0; i < 32; i++) {
      int sum = 0;
      for (int j = 0; j < n; j++) {
      sum += (nums[j] >> i) & 1;
      }
      sum = sum % 3;
      ans = ans | (sum

  • @kale-lb5pr
    @kale-lb5pr Před 4 měsíci

    array needs to be sorted i guess

  • @45_ritiksharma32
    @45_ritiksharma32 Před rokem

    Please solve longest palindromic subsequence leetcode -2484

  • @pindersingh4924
    @pindersingh4924 Před rokem +1

    i start my day with solving leetcode problem of the day , and then during breakfast i watch your solution video , love your videos.

  • @kanishparihar5497
    @kanishparihar5497 Před rokem

    class Solution {
    public:
    int singleNumber(vector& nums) {
    int ans = 0;
    for(int i=0;i

    • @GOLUKUMAR-zi9nv
      @GOLUKUMAR-zi9nv Před rokem

      It doesn't work for negative numbers

    • @jayantsahu6792
      @jayantsahu6792 Před rokem

      class Solution {
      public:
      int singleNumber(vector& nums) {
      int n = nums.size(), ans = 0;
      for (int i = 0; i < 32; i++) {
      int sum = 0;
      for (int j = 0; j < n; j++) {
      sum += (nums[j] >> i) & 1;
      }
      sum = sum % 3;
      ans = ans | (sum

  • @kale-lb5pr
    @kale-lb5pr Před 4 měsíci

    #include
    using namespace std;
    int singleNumII(vector a,int n)
    {
    int ones=0,twos=0;
    int i;
    for(i=0;i

  • @user-no5mo9jv5m
    @user-no5mo9jv5m Před rokem

    too much for me ! 😢

  • @harsh8174
    @harsh8174 Před rokem

    forrr 22222

  • @tejaspatel2212
    @tejaspatel2212 Před rokem +3

    38 min video 🤦🏻‍♂️. Who's gonna waste time.. why can't you make under 20 min video or split the video

    • @peachpink2831
      @peachpink2831 Před rokem +12

      why can't you check timestamp and skip to the part u need, you don't need to watch all 4 approaches

    • @kartikeyrana3736
      @kartikeyrana3736 Před rokem +1

      same lol, i'm waiting for neetcode to start uploading again, till then will have to make do with him.

    • @noobnessmee
      @noobnessmee Před rokem +7

      he can just cut his overactting and video would be 20 mins lol

    • @rohanpradhan3160
      @rohanpradhan3160 Před rokem +17

      Why are you saying that? If you don't enjoy it, simply choose not to watch it. You may inadvertently demotivate him from creating more content.

    • @harshal8781
      @harshal8781 Před rokem +3

      @@noobnessmee it's very easy to say anything about anyone, you should thanks him for such unique content on YT which no one explains the concept in such depth (and that you also know that's why you are here watching his videos 😛). It's easy to comment on someone, try it on your own you will realise it. And his expressions speaks how much dedicated he his with his work.✌️