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 :)
@Kitchen-Raccoon45724 жыл бұрын
lol he says that for so many problems and I get kinda sad when I hear that :(
@CoolnesXcore4 жыл бұрын
@@Kitchen-Raccoon4572 Don't get sad... Nick is a little arrogant plus he has been doing this for a while. Practice makes perfect!
@Turnpost25523 жыл бұрын
What most developers mean that it is relatively easy. Like it is relatively easy to get a phd than to become President. Both are exceptionally hard to get though.
@tasneemayham974 Жыл бұрын
For real!!!!! Sheesh I spend 2 hours just to figure out what is happening in my code!!
@impos1ble324 жыл бұрын
The solution with the single string HashSet looks like pure genius to me. Great video!
@samwilson4597 Жыл бұрын
big brain solution
@Ingenius33 жыл бұрын
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
@webknowledge99892 жыл бұрын
If you feel bad...don't. He spends a lot of time beforehand looking at different solutions, trying to come up with his own solutions, improve it and improving the different solutions he saw. And then, choosing the best one. This is pure hardwork.
@feeaven4 ай бұрын
This honestly was the simplest and best solution i've seen.
@shusenacademy4 жыл бұрын
Readable code is much better than smart code. Your solution is understandable. Thanks.
@johnhappy92308 ай бұрын
bro you have the best explanation that i've seen. Thank you so much
@pradeepanand52964 жыл бұрын
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.
@ruchirai57754 жыл бұрын
One word - Genius
@rutustup3963 жыл бұрын
The answer were already on leet code. 😅
@sicals17204 жыл бұрын
That moment when he first type the input for strings hash set is just simply mind blowing like "OMG off course it will works"
@Last_Resort9914 жыл бұрын
It will work better than your grammar teacher.
@a.human.3 жыл бұрын
@@Last_Resort991 when the grammar nazi doesn't know grammar himself lol
@khanshadab8063 жыл бұрын
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.
@danieljakel51054 жыл бұрын
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!
@PrinceKumar-el7ob3 жыл бұрын
Exploded my mind what a brilliant way to write aesthetic code man !!
@lugiadark213 жыл бұрын
This trick is INSANE!!!! I hope I never get asked a problem like this lol
@shubhamkhurana75454 жыл бұрын
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!!
@fabusuyiayodeji70164 жыл бұрын
Wow! This is the most intuitive solution I've seen to this problem
@enthusiasticsimple9013 жыл бұрын
Great Solution!! Thank Nick for posting these videoss
@aba01013 жыл бұрын
Brilliant!! Just to make sure, is the time and space O(1)?
@osamabassam75173 жыл бұрын
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).
@jordananders85253 жыл бұрын
Wouldn't this fail if one of the 3x3 squares looks like 1 2 3 4 5 6 7 8 9 and if there is another 3x3 square to the left or the right of the first 3x3 square that looks like 7 4 5 8 2 3 6 1 x where the x denotes an empty square, then this is an unsolvable Sudoku puzzle.
@decisive57602 жыл бұрын
It's doesn't matter if the sudoku puzzle is unsolvable. This leetcode problem is only checking for the three rules in the description
@seyikareem80524 жыл бұрын
Curios if it is possible to extend this solution to solve the Sudoku solver problem...
@soumi73563 жыл бұрын
This was a very different approach !
@DeepakAnand-x3f Жыл бұрын
Rather than using 3 hashsets using a single hashset was brilliant .
@lifeofme31722 жыл бұрын
WOW amazing solution loved it keep it up dude!
@Jdudeo4 жыл бұрын
The string concatenation allows using only one map, but what is the point of this? It's nifty, but I don't see a real reason to use this from a practical standpoint
@iamloking2 жыл бұрын
Loved the solution!
@dangbey48222 жыл бұрын
genious, thank you very much
@orangetree21044 жыл бұрын
Trivia : Nick White still has the hat used in his profile picture, and actually went to Columbia
@velmuruganr93213 жыл бұрын
wow..that blew my mind...I mean wow... Im speechless
@emanuelcristutiu58542 жыл бұрын
Really good explanation, thx mate!
@tushar_agarwal_it_2nd_a_4773 жыл бұрын
Can anyone give the cpp solution of this question,I am having some issues in my code.Thanks in advance:)
@suryakumar-ow8bx Жыл бұрын
its showing unexpected return value for return false line... wat to do
@Nickel804 жыл бұрын
What is the runtime for your solution? Is it O(n^2)?
@praharsh_bhatt4 жыл бұрын
Yes.
@divjyotsinghkhanuja15464 жыл бұрын
It is O(1). The for loop will always run for 9x9 grid irrespective of input if thats how you came up with O(n).
@divjyotsinghkhanuja15464 жыл бұрын
@wapanapoli How can the grid size change lol please explain
@Mark-tv1zs Жыл бұрын
@@praharsh_bhatt The grid is always 9x9 (even says in the video), so the time complexity is O(1)
@gopalchavan3062 жыл бұрын
wow Awesome, and I was spending hours to just solve this
@AbhishekAnand922 жыл бұрын
Brilliant solutions :D
@vrindatyagi67444 жыл бұрын
your vids are really helpful THANKS A LOAD
@jz-nz6tq4 жыл бұрын
this method is fucking genius
@NikhilTripathy4 жыл бұрын
WoW! That's so freaking cool..
@CodeSuccessChronicle3 жыл бұрын
Me: (video put on mute until he claps)
@inderjitsaini93033 жыл бұрын
I tried doing the nested if with normal (seen.add) instead of (!seen.add), return true and return false in outside the for loops. but that doesn't work. Can you tell why?
@vishnudarrshanorp3730 Жыл бұрын
in nested if statement you forgot to put ! symbol to check it..
@stutipandey25644 жыл бұрын
This is an awesomeeeeeee solution. I am mesmerized!!!! :)
@kulaisaikumarkulai73193 жыл бұрын
Great job
@DavisTibbz Жыл бұрын
Really? Snake_case in java? 😅 Anyway, cool content bro
@ServantOfLordKrishna.3 ай бұрын
this makes me look dumb
@SmokyBigSmoke4 жыл бұрын
Thank you so much
@WowPlusWow4 жыл бұрын
I did this in c++ and got only 6% faster. You also only got 22% This solution is a joke.
@_sudipidus_4 жыл бұрын
Leetcode's system of calculating this is flawed.. I have seen same thing submission showing up as faster than (12%-80%) and then back to 12% within a minute.. (network connection or something)
@sudhanshushakya45794 жыл бұрын
Hye, can you show me your cpp implementation? I am having trouble doing it. I used unordered_set in place of HashSet.
@bultvidxxxix99734 жыл бұрын
Because this solution is really bad for performance. It's a nice quick solution in a coding interview, but if you want fast execution times, you shouldn't even think about generating strings to hash them... It should more look like this: public boolean isValidSudoku(char[][] board) { for(int i=0; i
@yatinarora12523 жыл бұрын
@@sudhanshushakya4579 ya that will be work fine for rows use ur unordered_sename[i].(arr[i][j]and column use ur unordered set name[j].find(arr[i][j]) and array element arr[i][j] and for boads use following as it is 9^9 matrix use arr[i]j].find(arr[i][j]*3(i/3)*(j/3))
@Nathan00at78Uuiu2 жыл бұрын
I'm not understanding the logic and code for specifying a cube. It makes no sense to me.
@decisive57602 жыл бұрын
It's a 9x9 grid. A box is 3x3. If you divide the index of a row and column by 3, you get the box you're currently in.
@MrSharmagaurav032 жыл бұрын
This algorithm is wrong as it only check for first subset not all 9 subsets.
@driveb65914 жыл бұрын
Thanks for explaining. What's the time complexity?
@justdevthings.73974 жыл бұрын
O(n*n) where n is the size of the board
@yatinarora12523 жыл бұрын
LOL if we used three iterations instead of 1 iteration it will return 95% more faster solutions,in case of 1 iteration in c++ 35% only
@anuraggorkar22993 жыл бұрын
StefanPochmann sends regards ;)
@arjunsuresh273 жыл бұрын
worst explanation ever!! no intuition or walk through whats so ever cannot explain this in an interview!
@somyasrivastava63153 жыл бұрын
This is beautiful
@rashedulislam93014 жыл бұрын
nice explanation
@karana22604 жыл бұрын
does same number of elements in one hash Set or 3 hash set make a difference on memory usage? after all same units of memory is being allocated but pointers to each memory changes right? the type is same (char)
@thewatcherlollol4 жыл бұрын
Well yea, you're using more memory
@shravanipande79903 жыл бұрын
Yeah, even I had the same question.
@hopechan6974 жыл бұрын
really helpful thanks :3
@swatiswagatika20172 жыл бұрын
brilliant !!!!
@bobered4911 Жыл бұрын
Nick no filter white
@roshibansal20953 жыл бұрын
You look like sheldon
@pratheek50964 жыл бұрын
Clever as fuck
@jenblack80654 жыл бұрын
Explanation according to discussion, no details. Not worth to go through.
@ashwinishanbhogue29174 жыл бұрын
F R E A K I N G GeniusSSSSSSSSSSS!! :D Mind=blown :)
@amansaxena4446 Жыл бұрын
we dont know what u mean ,
@freesoul26773 жыл бұрын
It was a nice AHAAAAAAA moment =D Thank you!
@charanpasupula37633 жыл бұрын
Genius
@SudeepDasguptaiginition4 жыл бұрын
excellent !!!!
@algorithmimplementer4154 жыл бұрын
looks like you hate to use camelCase in the camelCase world of Java. :D
@divjyotsinghkhanuja15464 жыл бұрын
He codes in JS except for Data Structures I think thats where the underscores come from ;)
@channelname83004 жыл бұрын
WTF mannnnnnn...........................Destroyed it like a proooooo
@nknidhi3213 жыл бұрын
Mind boggling🔥
@ketansharma6955 Жыл бұрын
nice.
@julietgeorge48584 жыл бұрын
I hope you don't get tired of my comments but this is ridiculous(in a good way )