178 - Grid Challenge | Greedy | Hackerrank Solution | Python

Поделиться
HTML-код
  • Опубликовано: 21 авг 2024
  • ⭐️ Content Description ⭐️
    In this video, I have explained on how to solve grid challenge using sorting and simple logic in python. This hackerrank problem is a part of Problem Solving | Practice | Algorithms | Greedy | Grid Challenge and solved in python. The complexity of this solution is O (n log n).
    🔔 Subscribe: bit.ly/hackersr...
    🗓️ 1:1 Consultation with Me: calendly.com/h...
    📷 Instagram: / aswintechguy
    🔣 Linkedin: / aswintechguy
    🎯 GitHub: github.com/asw...
    🎬 Share: • 178 - Grid Challenge |...
    ⚡️ Data Structures & Algorithms tutorial playlist: bit.ly/dsatutorial
    😎 Hackerrank problem solving solutions playlist: bit.ly/hackerra...
    🤖 ML projects tutorial playlist: bit.ly/mlprojec...
    🐍 Python tutorial playlist: bit.ly/python3p...
    💻 Machine learning concepts playlist: bit.ly/mlconcepts
    ✍🏼 NLP concepts playlist: bit.ly/nlpconcepts
    🕸️ Web scraping tutorial playlist: bit.ly/webscrap...
    Make a small donation to support the channel 🙏🙏🙏:-
    🆙 UPI ID: hackersrealm@apl
    💲 PayPal: paypal.me/hack...
    #gridchallenge #hackerranksolutions #hackersrealm #hackerrank #sort #python #greedy #howtosolve #problemsolving #tutorial #algorithms #datastructures #programming #coding #codinginterview #education #aswin

Комментарии • 16

  • @mAcChaosCh
    @mAcChaosCh Год назад +2

    Your example was very helpful; I was beating my head against the wall for hours trying to figure out why my code wasn't working until I realized they described the problem wrong! It's supposed to be n x n grids, but it doesn't actually want that as the answer.

  • @affiliatemonster9136
    @affiliatemonster9136 2 года назад +3

    The way I solved it doesn't require sorting the characters in every row. I just picked the minimum character of each row and checked if they are in ascending order. That is, I check the minimum of the first row with the next row's minimum character, and keep incrementing rows. I remove the minimum characters if they are less than the minimum of the next row. If not, I return "NO".

    • @aquapisces
      @aquapisces Год назад +5

      your method:
      searching for minimum character O(n)
      deleting O(n)
      iterating O(n)
      total- O(n^3)
      admin's method:
      sorting O(nlogn)
      iterating O(n)
      total- O(n^2logn)

  • @user-tq3zn1wm1k
    @user-tq3zn1wm1k 11 месяцев назад +1

    Thanks for the video
    Actually, I did the same idea, but it doesn't pass all test. I am still debugging and have no idea what's going on. When it is obvious NO in the expected it must be YES and vice versa.
    But your code is literally the same idea as mine

  • @swastik07
    @swastik07 Год назад +3

    Hackerrank intentionally makes the problem statement wrong to an easy problem hard.

  • @matthewking8468
    @matthewking8468 2 года назад +1

    Very helpful. Thank you

    • @HackersRealm
      @HackersRealm  2 года назад +1

      Glad it was helpful!!!

    • @mufty9006
      @mufty9006 2 года назад

      @@HackersRealm very helpful video Thank You
      But wouldn't row = len(grid[0]) and col=len(grid) rather?

    • @HackersRealm
      @HackersRealm  2 года назад

      @@mufty9006 No, it's the opposite

  • @vyshakkriss7765
    @vyshakkriss7765 2 года назад +1

    Thanks

  • @trinhhuynhthinhkhang3384
    @trinhhuynhthinhkhang3384 Год назад

    sir, I try it in another test case, this fail, I detect that .sort() didn't change the grid so I have to use grid[i] = sorted(grid[i])

  • @tularamsa5814
    @tularamsa5814 2 года назад +1

    awesome

    • @HackersRealm
      @HackersRealm  2 года назад

      Glad you liked it!!!

    • @tularamsa5814
      @tularamsa5814 2 года назад +1

      update:
      it worked bro , i was doing some mistake at iteration part of column 🙃😵🧐