Row With Maximum 1s | Arrays | 2-D Array | GeeksForGeeks | LeetCode | Explanation by alGOds!!!

Sdílet
Vložit
  • čas přidán 7. 09. 2024
  • In this video, Vishesh Aggarwal has explained the optimized approach for solving the question #RowWithMax1s from #GeeksForGeeks and is asked in #Google #Amazon #Microsoft #FAANG
    Question Link - practice.geeks...
    Solution for Reference - ide.geeksforge...
    Feel free to ask any of your doubts and discuss your attempts related to this question in the comments section 😇.
    Join this telegram channel for regular updates : t.me/alGOdsYou...
    Join this telegram channel for doubts and discussions : t.me/joinchat/...
    Do like and subscribe to our channel and click the bell icon so you don’t miss any future videos!!.
    Don’t forget to tell us about the Questions you need an explanatory video for in the comments section. We’ll definitely take care of it😁.
    Here is the Subscription Link : / algods99
    Connect with us on Gmail : algods.99@gmail.com
    The contributors to this channel and their profile links are enlisted below
    1) Vishesh Aggarwal:
    LinkedIn :- / vishesh-aggarwal-830b5...
    2) Vaibhav Varshney:
    LinkedIn :- / vaibhav-varshney
    3) Vagish Yagnik:
    LinkedIn :- / vagish-yagnik-9203b0172
    4) Vishesh Jain:
    LinkedIn :- / vishesh-jain-138097174
    5) Achint Dawra:
    LinkedIn :- / achint-dawra-ba9550168
    6) V Sriram:
    LinkedIn :- / sriram-v-08b098170
    7) Varun Bajlotra:
    LinkedIn :- / varun-bajlotra-17715a170
    8) Vikas Yadav:
    LinkedIn :- / vikas-yadav-b432b5107

Komentáře • 48

  • @alGOds99
    @alGOds99  Před 4 lety +2

    Join this telegram channel for regular updates : t.me/alGOdsCZcams
    Join this telegram channel for doubts and discussions : t.me/joinchat/PqjeMhz0MBR-tg31OK2Dsg

  • @algoman6589
    @algoman6589 Před 2 lety +4

    we can also do one thing just iterate cloumn wise when the very first 1 come then return its row number
    for(int j=0;j

    • @rdxgaurav3483
      @rdxgaurav3483 Před 2 lety

      Nice buddy

    • @vishwan7280
      @vishwan7280 Před 2 lety +1

      take the case where all the rows but one have all the elements as 0
      example {0000,0000,0000,0000,0000,0000,0000,0000,0001}, here when your logic is applied the time complexity will turn out to be O(N*M), nice solution though :)

    • @rdxgaurav3483
      @rdxgaurav3483 Před 2 lety +1

      @@vishwan7280 you can't optimise this case 😂 , so this is the best solution I guess , or some bitmagic may do fine

    • @Varun-id6fi
      @Varun-id6fi Před rokem

      o(m*n)

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

      @@vishwan7280 you can use the logic mentioned in the video which must be optimal since you can eliminate the all the rows once you encounter 0.but int his case 0111,0111,0111,1111 the time complexity is near about O(m*n)

  • @9dsong782
    @9dsong782 Před 3 lety +4

    thank you for the good explanation
    one subscriber is increased😁😄
    keep uploading a video like this 🤞👍

  • @momozkichutney
    @momozkichutney Před 3 lety +2

    And what of we don't get any one 1 in first row??
    Then do we need to search in next row..until we don't get the row with 1??

  • @AlgorithmHQ
    @AlgorithmHQ Před rokem +1

    bhari explanation 🤩🤩mast

  • @bluemeet8546
    @bluemeet8546 Před 3 lety +1

    thanks for such a wonderful explaination

  • @subrinasirajee530
    @subrinasirajee530 Před 3 lety +1

    Nice explanation. Thanks a lot.

  • @funcode-tw3cg
    @funcode-tw3cg Před rokem

    thankss for tthis wonderful explaination brother!

  • @shantanumapari6679
    @shantanumapari6679 Před rokem

    wonderful solution!!

  • @notcountdankula
    @notcountdankula Před rokem

    Python code:
    def rowWithMax1s(matrix: [[int]], n: int, m: int) -> int:
    if matrix[0][0] == 1:
    return 0
    rowCount = 0
    count = 0
    row = -1
    r = 0
    c = m - 1
    while r < n and c >= 0:
    if matrix[r][c] == 1:
    count = m - c
    c -= 1

    if count > rowCount:
    row = r
    rowCount = count
    else:
    r += 1
    return row

  • @TheCodeHub
    @TheCodeHub Před 2 lety +1

    But the expected time complexity is O(N+M)

  • @pranaykumar9433
    @pranaykumar9433 Před 3 lety +4

    the code in the description fails at test case 2 1
    00
    00
    extra condition if(j==m-1)
    return -1;

  • @ziyasayed896
    @ziyasayed896 Před 2 lety

    binary search method won't work because Binary search does not return the index of the first occurrence of 1

    • @rishavraj5932
      @rishavraj5932 Před 2 lety +2

      I think you can modify the binary search to find the first and last occurrence of any target element

  • @dharmeshpoladiya5356
    @dharmeshpoladiya5356 Před 2 lety

    Great Explanation
    Subscriber++;

  • @rohandevaki4349
    @rohandevaki4349 Před 2 lety

    you havent written any code too , so how will you say that your algorithm works?

  • @rohandevaki4349
    @rohandevaki4349 Před 2 lety

    how will you make the binary search , search the first one? at 2:42 ?

    • @rishavraj5932
      @rishavraj5932 Před 2 lety

      for the first one also linear search is used I guess but from last index that is (m-1)

  • @prakharagarwal6237
    @prakharagarwal6237 Před 3 lety

    Thanks brother!

  • @mananpurohit9299
    @mananpurohit9299 Před 2 lety

    Nice video

  • @avadhnarayanyadav5981
    @avadhnarayanyadav5981 Před 4 lety +1

    Best 👌🏼👌🏼👌🏼

    • @alGOds99
      @alGOds99  Před 4 lety

      Thanks!!
      Do share our channel among your friends and college mates if you found our content useful😊

  • @sudhanshumishra5796
    @sudhanshumishra5796 Před 3 lety +2

    what if the matrix is
    00
    00
    aur waise bhi ye m*n ki tym complexity hai

    • @vivekswami2182
      @vivekswami2182 Před 2 lety

      After second for loop put this condition
      if(j==m-1)
      return -1;

  • @Asurgaming773
    @Asurgaming773 Před rokem

    bhai code klha hai ??

  • @shashankreddy4620
    @shashankreddy4620 Před rokem

    disappointed u should have included code

  • @namangarg4845
    @namangarg4845 Před 3 lety

    can anyone send me the code in python for last approach which he have mention in the video

  • @saidikshith1895
    @saidikshith1895 Před 2 lety

    can you do it in python

  • @justanaverageguy4739
    @justanaverageguy4739 Před 3 lety +3

    shit this was so simple poor me !

    • @kamalkumar945
      @kamalkumar945 Před 3 lety

      the same bro,🤣🤣🤣 I did not notice that sorted row is given😶

  • @ajaywadhwa3398
    @ajaywadhwa3398 Před 3 lety

    In the last approach,
    for a test case where all elements in 2D matrix is 0 , How can be the complexity is (n+m)
    {
    0,0,0,0,0
    0,0,0,0,0
    0,0,0,0,0
    0,0,0,0,0
    0,0,0,0,0
    }

    • @UR0Cristiano
      @UR0Cristiano Před 3 lety +1

      he is talking about worst complexity.

    • @dillitimalsina6003
      @dillitimalsina6003 Před 2 lety

      bro if all elements are 0 then it's t.c will become o(n) only not even o(n+m) because it checks all row's last element ino(n) and outer row check loop will ends and it just returns without checking haha so simple

  • @nter_10_ment52
    @nter_10_ment52 Před 2 lety

    bhai leetcode me implement kr deta

  • @rishabhgoyal2835
    @rishabhgoyal2835 Před 4 lety

    explanation is best.......but plz share code with it ,,,, without code it is useless.............

    • @alGOds99
      @alGOds99  Před 4 lety

      Hi Rishabh! We always provide the solution link in the description. You can check it there :)

    • @satishbahuguna3349
      @satishbahuguna3349 Před 3 lety

      Where is the code I couldn't find it please share

    • @alGOds99
      @alGOds99  Před 3 lety

      Check the description : )

    • @satishbahuguna3349
      @satishbahuguna3349 Před 3 lety

      Hey kindly upload more vedios for competitive coding .

    • @satishbahuguna3349
      @satishbahuguna3349 Před 3 lety

      I m finding difficulty in maximum profit in selling share twice problem. So if you could help me with this.

  • @praveengautam4689
    @praveengautam4689 Před rokem

    your intro is cringy as f... ur good in explaination