LeetCode 36. Valid Sudoku (Algorithm Explained)

preview_player
Показать описание


Preparing For Your Coding Interviews? Use These Resources
————————————————————

Other Social Media
----------------------------------------------

Show Support
------------------------------------------------------------------------------

#coding #programming #softwareengineering
Рекомендации по теме
Комментарии
Автор

at 9:08 when he said it is not difficult, my face turned into red. If I've never saw this kind of solution before, I would be doomed in a interview :)

calfland
Автор

The solution with the single string HashSet looks like pure genius to me.

Great video!

imposble
Автор

Huh, the advantages of knowing your data structures and methods...I've spent 10+ hours on a similar sudoku problem and been trying to use only arrays and 2d arrays combined with control statements, and it's been a nightmare to be honest, and now I see this and I really think I gotta learn some data structures, it's ridiculous how fast you can come up a solution like this

Ingenius
Автор

Readable code is much better than smart code. Your solution is understandable. Thanks.

shusenacademy
Автор

This honestly was the simplest and best solution i've seen.

feavenmundo
Автор

Curios if it is possible to extend this solution to solve the Sudoku solver problem...

seyikareem
Автор

bro you have the best explanation that i've seen. Thank you so much

johnhappy
Автор

This is lit. No words. I solved the arcade section of the sudoku by using two hashset one for row and one for column. Never thought this could be the way to optimise the code.

pradeepanand
Автор

Brilliant!! Just to make sure, is the time and space O(1)?

aba
Автор

Exploded my mind what a brilliant way to write aesthetic code man !!

PrinceKumar-elob
Автор

That moment when he first type the input for strings hash set is just simply mind blowing like "OMG off course it will works"

sicals
Автор

Wow! This is the most intuitive solution I've seen to this problem

fabusuyiayodeji
Автор

This was a really cool solution Sir, so we can also implement even a string matching algo using string datatype hash set. This problem really teaches a cool concept!! Thank You Sir!!

shubhamkhurana
Автор

You could also make a list of 81 list with 9 entries each for every field and number that is possible. Then you write a algorithm that cross out each number from the nine possibilieties that has a double in line, colum or quadrat. When all numbers cut one in a list are crossed out, you have found a new one that you can use to delete the other list of posibilities. If each list have just a number its solved!

danieljakel
Автор

Great Solution!!
Thank Nick for posting these videoss

enthusiasticsimple
Автор

A clever solution, but the simple solution (Validating rows, columns, and boxes seperately) is way more faster, for me this solution beat 100% of java solution in term of time, the solution in the video beat 22% only (Which is because of strings hashing I guess).

osamabassam
Автор

Can anyone give the cpp solution of this question, I am having some issues in my code.Thanks in advance:)

tushar_agarwal_it_nd_a_
Автор

This trick is INSANE!!!! I hope I never get asked a problem like this lol

lugiadark
Автор

Also, you could remove the big 'if' from the 'for' loop and just check if the size of the set is 3*(Number of non-empty places in the board) after the loop. If it is not, the answer is false.

khanshadab
Автор

WOW amazing solution loved it keep it up dude!

lifeofme