Maximum XOR Pair Using Trie

Поділитися
Вставка
  • Опубліковано 19 лют 2018
  • Get COURSES For FREE Using This Scholarship Test. Register Here Now: www.codingninjas.com/landing/... Maximum XOR Pair Using Trie by - Parikh Jain
    Online course insight for Competitive Programming Course. Visit for more details: www.codingninjas.in/app/cours...
  • Наука та технологія

КОМЕНТАРІ • 78

  • @9ShivamSharma
    @9ShivamSharma 6 років тому +39

    5:20 it is right shift only , not left shift .

  • @Sushil2874
    @Sushil2874 4 роки тому +1

    Nicely explained...
    Thank You..!!

  • @dharmikjoshi5728
    @dharmikjoshi5728 5 років тому +3

    Perfection!!

  • @chandrikagarg4337
    @chandrikagarg4337 4 роки тому

    You explained it very well. Great video .Thank you

  • @akash02ab
    @akash02ab 3 роки тому +4

    Can this method also be applied for finding maximum AND pair?

  • @dhruvrajpurohit7341
    @dhruvrajpurohit7341 4 роки тому

    Simply Great!

  • @RaviKumar-vk6ib
    @RaviKumar-vk6ib 4 роки тому

    awesome !!! very simple and concrete ideas

  • @niteshnijhawan3856
    @niteshnijhawan3856 4 роки тому +1

    Bro the method was amazing, but do we have any other method in which we need not perform the operation for every element of the array?

  • @kaustubhgarg9662
    @kaustubhgarg9662 4 роки тому

    Brilliant! Brilliant!

  • @marazak6390
    @marazak6390 3 роки тому

    Beautiful Explanation!!

  • @fuadhasan0362
    @fuadhasan0362 6 років тому

    thanks :) nice explanation...

  • @sarfarazalam6077
    @sarfarazalam6077 4 роки тому

    Great explanation , thanks for video :)

  • @bhagirathinayak1266
    @bhagirathinayak1266 6 років тому

    Amazing!

  • @shreyassingh7065
    @shreyassingh7065 5 років тому +4

    I think you are wrong at the point that in the worst case you will traverse your same path ( which you are explaining at 13th minute). Well, the point is correct but the logic isn't. In case we start from 0 so we go to 1 for finding max. xor (lets say it exists ) but now we have left the current element. Hence the logic for why we don't need to worry about curr getting null is wrong. The correct reason is that at which ever point we deviate all numbers will be 32 bit long and hence at any point there is a guaranteed that it will lead us to the leaf because no path will be of length less than 32.

    • @readmeCarefully
      @readmeCarefully 3 роки тому

      Yea u r right..thanks for clarifying.. actually the statement can confuse someone..with a problem to find max zor of array with elements other than the array's elements

  • @AnubhavShrivastava
    @AnubhavShrivastava 5 років тому

    awesome !!

  • @Sanjeev.Network
    @Sanjeev.Network 4 роки тому

    Awesome Explaination

  • @madhavgaba7617
    @madhavgaba7617 5 років тому +1

    Great video, I was not able to fully understand it with geeks and other sources

  • @lovleshbhatt7797
    @lovleshbhatt7797 4 роки тому

    I think we cannot solve maximum pairwise AND or OR in an array Question using this trie technique?? because we cant distinguish the path is of our ith part of not..
    correct me if I m wrong.

  • @mr.curious1329
    @mr.curious1329 2 роки тому

    Very very good!!
    Pls sir aur videos daliye, plssssss.

  • @abhishekashware4781
    @abhishekashware4781 2 роки тому

    I think we should check only 31 bits. Hence initialisation of j must be 30 instead of 31.

  • @KunalKumar-ex9gm
    @KunalKumar-ex9gm 4 роки тому

    Brilliant explanation

  • @Igloo11
    @Igloo11 3 роки тому +1

    Finally, I able to understand this problem. Thank you:)

    • @CodingNinjasIndia
      @CodingNinjasIndia  10 місяців тому

      Thank you for the kind words! We hope that this video has helped you!
      Stay tuned to Coding Ninjas UA-cam channel for more such content! Do check our Coding Ninjas Studio, where you can upskill for free and become a Ninja Coder: www.codingninjas.com/studio/home?
      If reading is your preference, you can find top articles to upskill in your career here: www.codingninjas.com/studio/library?
      If you would like to opt for a Coding Ninjas course, you can check our courses here: www.codingninjas.com/?

  • @ashokpalle1417
    @ashokpalle1417 5 років тому

    wow..nice explanation

  • @nikhilrathore2385
    @nikhilrathore2385 5 років тому +1

    where is the approach video

  • @ravishasharma1219
    @ravishasharma1219 3 роки тому

    Clear!

  • @amritanshu83
    @amritanshu83 3 роки тому

    Very nice and simple explanation bro..Keep it up!

  • @abe10
    @abe10 4 роки тому

    This is brilliant!

  • @shivanshbajpai588
    @shivanshbajpai588 2 роки тому

    Thanks for the simple most explanation i have been confused on this question for a very long time
    Really Thanks

    • @CodingNinjasIndia
      @CodingNinjasIndia  10 місяців тому

      Thank you for the kind words! We hope that this video has helped you!
      Stay tuned to Coding Ninjas UA-cam channel for more such content! Do check our Coding Ninjas Studio, where you can upskill for free and become a Ninja Coder: www.codingninjas.com/studio/home?
      If reading is your preference, you can find top articles to upskill in your career here: www.codingninjas.com/studio/library?
      If you would like to opt for a Coding Ninjas course, you can check our courses here: www.codingninjas.com/?

  • @subham-raj
    @subham-raj 4 роки тому +1

    Thank you brother

    • @subham-raj
      @subham-raj 4 роки тому +1

      This is a similar problem --> www.hackerrank.com/challenges/maximum-xor/

  • @abufarhad5691
    @abufarhad5691 3 роки тому

    Clearly Understand, Thank you.

    • @CodingNinjasIndia
      @CodingNinjasIndia  10 місяців тому

      Thank you for the kind words! We hope that this video has helped you!
      Stay tuned to Coding Ninjas UA-cam channel for more such content! Do check our Coding Ninjas Studio, where you can upskill for free and become a Ninja Coder: www.codingninjas.com/studio/home?
      If reading is your preference, you can find top articles to upskill in your career here: www.codingninjas.com/studio/library?
      If you would like to opt for a Coding Ninjas course, you can check our courses here: www.codingninjas.com/?

  • @aliasgar1648
    @aliasgar1648 5 років тому +2

    Awesome video man ! I think you were correct to say right shift to find the current bit

    • @Sanjeev.Network
      @Sanjeev.Network 4 роки тому

      Buy the Course and get DISCOUNT OF RS:- 1200 + 35%OFF Use this Link:- codingninjas.in/app/invite/ZVUAQ for you.

  • @deepanshumahour3318
    @deepanshumahour3318 3 роки тому +1

    Thank you very much, brother...It really helped me to understand this topic entirely

    • @MangoLassiYT
      @MangoLassiYT 2 роки тому

      why did we take 32 bits please explain me please

    • @CodingNinjasIndia
      @CodingNinjasIndia  10 місяців тому

      Thank you for the kind words! We hope that this video has helped you!
      Stay tuned to Coding Ninjas UA-cam channel for more such content! Do check our Coding Ninjas Studio, where you can upskill for free and become a Ninja Coder: www.codingninjas.com/studio/home?
      If reading is your preference, you can find top articles to upskill in your career here: www.codingninjas.com/studio/library?
      If you would like to opt for a Coding Ninjas course, you can check our courses here: www.codingninjas.com/?

  • @sidhantakumarpattnaik2962
    @sidhantakumarpattnaik2962 4 роки тому

    Very Good explanation ..

  • @gauravpahuja1114
    @gauravpahuja1114 3 роки тому +1

    Great video

  • @ajourney179
    @ajourney179 4 роки тому

    awesome.

  • @MangoLassiYT
    @MangoLassiYT 2 роки тому

    why did we take 32 bits please explain me please

  • @divyanshugupta2695
    @divyanshugupta2695 2 роки тому

    well explained

  • @anirudhatalmale5575
    @anirudhatalmale5575 3 роки тому

    awesome explanation

  • @satyam5036
    @satyam5036 2 роки тому

    Isn't there O(n) approach?

  • @sunilmaurya1572
    @sunilmaurya1572 6 років тому

    Nice explanation .Upload some more videos on BIT MANIPULATION . keep it up

  • @anjurawat9274
    @anjurawat9274 4 роки тому

    easy and clear explanation _/\_

  • @yadnyeshpatil7662
    @yadnyeshpatil7662 4 роки тому

    Beautiful

  • @RAVIKUMAR-ef4wo
    @RAVIKUMAR-ef4wo 5 років тому

    awesome bhai...you rock ...i love you

    • @Sanjeev.Network
      @Sanjeev.Network 4 роки тому

      Buy the Course and get DISCOUNT OF RS:- 1200 + 35%OFF Use this Link:- codingninjas.in/app/invite/ZVUAQ for you.

    • @astroash
      @astroash 3 роки тому

      i love you ravi

  • @ManishKumar-bl6gy
    @ManishKumar-bl6gy 5 років тому

    great video sir. hope you will make video on "MAXIMUM SUBARRAY XOR"

    • @Sanjeev.Network
      @Sanjeev.Network 4 роки тому

      Buy the Course and get DISCOUNT OF RS:- 1200 + 35%OFF Use this Link:- codingninjas.in/app/invite/ZVUAQ for you.

  • @swapnil1108
    @swapnil1108 4 роки тому

    Amazing explanation! hats off to you

  • @apoorvagarwal9622
    @apoorvagarwal9622 3 роки тому

    i have a question why on line 50 we need to do curr_xor += pow(2,j) ?

    • @ajaykumarsahu3517
      @ajaykumarsahu3517 3 роки тому +1

      To add the value to the current XOR value...if you found XOR to be 1 at any position (bit) then you need to add 2 raised to the power of that position as 1 is multiplied with that power of 2

  • @sujoyseal195
    @sujoyseal195 3 роки тому

    Mazaa aa gya bro

  • @avinashmanyam
    @avinashmanyam 4 роки тому

    em cheppav bhayya 👌

  • @sahil16184
    @sahil16184 6 років тому

    What if we need to find a xor pair which is greater than some given value?

    • @prateekgupta9889
      @prateekgupta9889 5 років тому

      In findmax pair function, set max_xor = some given value, it will give you the same value or greater

    • @Paradise-kv7fn
      @Paradise-kv7fn 4 роки тому +1

      @@prateekgupta9889 the maximum xor pair will also always be greater than the given value as long as the answer exists...so you can return the maximum xor pair itself...however, if k>pow(2,log(max(arr)))+1 then no such pair would exist

  • @satyam5036
    @satyam5036 2 роки тому

    It's not O(n) solution

  • @ankitbhardwaj9566
    @ankitbhardwaj9566 3 роки тому

    pow(2,j-1) nahi add hona chahiye??

  • @cicciopasticcio8469
    @cicciopasticcio8469 3 роки тому +1

    Which language are you speaking?

  • @s.balaji5016
    @s.balaji5016 4 роки тому

    add subtitles coder..

  • @ankitbhardwaj9566
    @ankitbhardwaj9566 3 роки тому

    j he hoga,got that

  • @shubhamshandilya3047
    @shubhamshandilya3047 4 роки тому

    can anyone help me in calculating the space complexity to above approach

    • @tanujkalra7334
      @tanujkalra7334 4 роки тому

      If Each TrieNode occupies a memory of K bytes, then there will be 32 nodes for each Number hence total space Occupied by each number is (32*K) which is constant say M.
      Now,we have N numbers so total space would be N*M where M is almost constant so,Space complexity becomes O(N)!

  • @abhishes
    @abhishes 6 років тому

    10:29 but thats not o(n).

    • @saiswaroop5889
      @saiswaroop5889 5 років тому +2

      dude, the inner loop will always run for 32 times. so O(31n) = O(n)

    • @ravitejavankam2977
      @ravitejavankam2977 4 роки тому

      @@saiswaroop5889 it's not 31n it's 32nlogm which gives a complexity of nlogm as m is the size of number for logm for calculating pow

  • @shubhamk840
    @shubhamk840 3 роки тому

    This guy always explains in the best way possible.

  • @ayushgarg5539
    @ayushgarg5539 5 років тому

    Thanks from US :)

  • @adityasinghaswal4923
    @adityasinghaswal4923 2 роки тому

    Brilliant explanation