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
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.
yeah sometimes, it happens
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".
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)
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
Hackerrank intentionally makes the problem statement wrong to an easy problem hard.
Very helpful. Thank you
Glad it was helpful!!!
@@HackersRealm very helpful video Thank You
But wouldn't row = len(grid[0]) and col=len(grid) rather?
@@mufty9006 No, it's the opposite
Thanks
Glad it's helpful!!!
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])
awesome
Glad you liked it!!!
update:
it worked bro , i was doing some mistake at iteration part of column 🙃😵🧐