Flip Columns For Maximum Number of Equal Rows - Leetcode 1072 - Python

แชร์
ฝัง
  • เผยแพร่เมื่อ 22 ม.ค. 2025

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

  • @33galactus
    @33galactus 2 หลายเดือนก่อน +13

    The aim of the problem is to match the maximum number of rows. The key idea is that no matter how many columns you flip, if two rows are not identical or inverses of each other, they can never be matched. Once you realize this, the solution becomes straightforward. Indeed, a genius solution - thanks Navdeep!

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

    this solution is seriously genius...

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

    Even after looking through solutions and understanding the logic, i just can’t convince myself that i would be able to come up with this in an interview myself, or probably if i come back to this same problem after few months. How do you guys even come up with thinking in terms of equating rows when the question is about columns? Or even just if someone can explain general thought process for such problems, as this does not fall under any patterns.. Need help! I feel stuck :/

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

      I think that these kinds of problems are some of the hardest, where there’s no pre-learned algorithm to apply, and it requires a brilliant insight to solve.
      I think that the key to maximizing your chances of solving a problem like this are using problem solving strategies like he explained in the video.
      1. Make general observations about the problem (inverted matrices are equivalent)
      2. See if you can solve an easier version of the problem (2 rows instead of matrix)
      3. Try to generalize based on the easier version of the problem (inverted rows are equivalent!)

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

    You are fueling people's dreams in ways you might not even realize, and your impact is truly profound. It's hard to express how much we rely on you and how you have made us believe in ourselves. Genuinely don’t know what we would do without you.

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

    man at this point you are master shifu

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

    Thank you for continuing to make these videos

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

    Such a nice explanation, we just need to go through as many examples we cound and try to make observation out of it. I could say this is true for all matrix problems.

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

    This solution is insane 💯💯

  • @siddharth-gandhi
    @siddharth-gandhi 2 หลายเดือนก่อน +4

    Bro has all questions till next year cached

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

    Very Nice Explanation, Thank you so much

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

    How can we do if the problem asks to return the minimum number of column flips to get maximum number of equal rows

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

    Man, that is a seriously clever trick for this problem.

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

    Thank you for explanation. I love it

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

    solid solution !

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

    Can someone explain to me why are we checking if the first value in a row is 1 before inverting it?

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

      If its same or inverse, they should be considered and added to the map as single key.
      So, just for standard, he is considering all start with 0.. So, if anything starts with 1, that will be inversed and added as same key..

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

      @_abhishekmj_ why can't we add all the strings and their inverse to the map and check for maximum frequency to get the answer?

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

      @@-ArnobBiswas Works, but that way the map will be double the size .. And also 2 times iterating the matrix..

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

    legend 🙏

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

    Will there be a Black Friday deal for Neetcode Pro?

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

    3:04 Neuron activated

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

    Sometimes interview is like IQ test, that's why I am not valid for cracking big tech interview even though I am confident on those classic problems and its variant ones.
    Hard to get a ETA for reaching the goal

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

    I wonder if there will come a day when I will we be able to make such observations

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

    today i learned that python handles int overflows under the hood, the more you know

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

    After the 3rd example I understood the pattern that once we flip the columns compliment rows are giving same rows. If not for the third example, I don't know how to solve this problem

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

    Can anyone suggest how you wud do it in dynamic programming way..? So, I will understand how we think dynamic programming..

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

    when i ran the exact code, i got 99.07%, good job

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

    I am trying to race you and i lost again lol

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

    bro please solve leetcode 493.Reverse Pairs

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

    What's a "string"? I only know arrays of chars :)

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

    👍

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

    solution is so tricky

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

    but how are we checking if all values in row are equal? isn't that what the question asks? to find the number of rows that have equal values. maybe I am interpreting in a different way than you, but you mean to say that inverse of a row can be made to have equal values in each single row?

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

      If two rows are different, and are not the inverse of each other, it's impossible to make them meet the criteria of the problem statement. Thus, we can solve the problem by counting.

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

      Basically, if you’re checking maximum of how many rows are equal to each other, you are doing two things indirectly:
      1. Calculating the number of rows where all the individual values(columns) for that row are equal.
      2. Grouping them together when either they are exactly equal or equal complementarily and getting it’s count. Explanation: So, when you simulate flipping the columns, all the values in grouped rows become equal, because you’re doing the exact same operation just on its complimentary value
      Ex: if you have 110 and 001 you group them together, so if you flip last column of both, you get two rows for each of them have same values 111 and 000 respectively
      So indirectly by grouping the same rows together, the maximum count of similar grouping tells you that if you flip n columns, in this grouping, these are the maximum rows that have all the values equal
      Even I had trouble understanding, thinking in terms of equating rows when we are asked about columns, but writing it down on a paper made it clear for me, Though I still think for me, it is difficult to come up in a real interview setting

    • @SaravananV-mn9et
      @SaravananV-mn9et 2 หลายเดือนก่อน

      I guess, as long as two rows are equal, you can flip the desired columns and make all the values equal

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

    why this is wrong ?
    class Solution {
    public:
    int maxEqualRowsAfterFlips(vector& matrix) {
    int n = matrix.size();
    int flip = 0;

    for (int i=0; i

  • @GANESHKUMAR-ww9dv
    @GANESHKUMAR-ww9dv 2 หลายเดือนก่อน

    At this point, you have any questions that you are not able to solve? Please reply

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

    holy shit