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

แชร์
ฝัง
  • เผยแพร่เมื่อ 21 พ.ย. 2024

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

  • @33galactus
    @33galactus 8 ชั่วโมงที่ผ่านมา +4

    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 13 ชั่วโมงที่ผ่านมา +14

    this solution is seriously genius...

  • @SinchanaR-jp5zi
    @SinchanaR-jp5zi 31 นาทีที่ผ่านมา

    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.

  • @vijethkashyap151
    @vijethkashyap151 10 ชั่วโมงที่ผ่านมา +11

    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 :/

  • @meganova609
    @meganova609 10 ชั่วโมงที่ผ่านมา +4

    man at this point you are master shifu

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

  • @yang5843
    @yang5843 13 ชั่วโมงที่ผ่านมา +3

    Thank you for continuing to make these videos

  • @avishjain7375
    @avishjain7375 10 ชั่วโมงที่ผ่านมา

    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.

  • @jamestwosheep
    @jamestwosheep 6 ชั่วโมงที่ผ่านมา

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

  • @mingchieh
    @mingchieh 5 ชั่วโมงที่ผ่านมา

    Thank you for explanation. I love it

  • @unlucky-777
    @unlucky-777 6 ชั่วโมงที่ผ่านมา

    This solution is insane 💯💯

  • @prathameshchakote6152
    @prathameshchakote6152 7 ชั่วโมงที่ผ่านมา

    Very Nice Explanation, Thank you so much

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

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

  • @tusov8899
    @tusov8899 7 ชั่วโมงที่ผ่านมา +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

  • @siddharth-gandhi
    @siddharth-gandhi 12 ชั่วโมงที่ผ่านมา +2

    Bro has all questions till next year cached

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

    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

  • @tommasocerruti998
    @tommasocerruti998 2 ชั่วโมงที่ผ่านมา

    legend 🙏

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

    solution is so tricky

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

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

  • @-ArnobBiswas
    @-ArnobBiswas 8 ชั่วโมงที่ผ่านมา +1

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

    • @_abhishekmj_
      @_abhishekmj_ 4 ชั่วโมงที่ผ่านมา

      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 3 ชั่วโมงที่ผ่านมา

      @_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..

  • @_abhishekmj_
    @_abhishekmj_ 4 ชั่วโมงที่ผ่านมา

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

  • @maganrakhra3209
    @maganrakhra3209 13 ชั่วโมงที่ผ่านมา +2

    I am trying to race you and i lost again lol

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

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

    for (int i=0; i

  • @rickastley4_the_second
    @rickastley4_the_second 11 ชั่วโมงที่ผ่านมา

    👍

  • @satyadheeraj6081
    @satyadheeraj6081 8 ชั่วโมงที่ผ่านมา

    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  8 ชั่วโมงที่ผ่านมา +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 8 ชั่วโมงที่ผ่านมา

      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 3 ชั่วโมงที่ผ่านมา

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