Pass Your Next Tech Interview With Valid Sudoku

preview_player
Показать описание
Tech interviews suck, but almost every big tech company requires them at some point. Since I myself am still learning how to better solve program-related interview questions, I figured why not hammer in those concepts by creating a full-fledged animation on algorithm related topics, while sharing it with the world so everyone can have an easier time with interviews.

This video will demystify some of the complex and abstract concepts that accompany programming related interview questions such as validating a provided sudoku board. Hope it helps!

0:00 Intro to sudoku and validation
2:10 Validate rows
2:52 Validate columns
3:59 Validate 3x3 boxes
6:12 Bye bye

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

Your video editing and explanation is awesome.
I want to show them in school

FlanderDev
Автор

This is the most detailed and understand able explanation of this problem I have seen so far

barssavas
Автор

Great stuff man. You're really doing the community a service by putting out this content. Thanks for sharing!

dbroche
Автор

Animations are great and the explanation is easy to understand. Thank!

shayshay
Автор

I have never played sudoku never could i understand the game when someone tried explaining it to me until now! thank you so much!

BlissAden
Автор

Thank you for this man, this video really resonated with me. I'm fairly comfortable with 2d arrays but even still I felt enlightened a bit after watching.

WL
Автор

Chris, you must know many of us are trying to work out if your animations here were built on an html canvas. And yes, if so, we'd really love a walk-through video. Great work, thanks.

batchrocketproject
Автор

best video solution i found in leetcoding

thiagow
Автор

Amazing animations. Make it very clear.

fablouping
Автор

But how do I think of such formula??
Anyway you explained so well just in 6 minutes.

serial_coder
Автор

The presentation for this was amazing and concise. Seriously, thank you so much. Not prepping for interviews but this is my second bootcamp project. The visual aids helped a lot in seeing what is going on.

HigkeyRegarded
Автор

This is not real sudoku - there are repeated digits (1, 5, 7) in main (long) diagonals. In your example perfect Sudoku is:

Row 1: 534 678 912
Row 2: 912 534 678
Row 3: 678 912 534
Row 4: 345 786 129
Row 5: 129 345 786
Row 6: 786 129 345
Row 7: 453 867 291
Row 8: 291 453 867
Row 9: 867 291 453

It is easy to make this in (for example) Python/JS code.

krzysztofsobota
Автор

Why does anyone apply for a programmer job who doesn't know what a 2darray is and how to traverse it?

stagesol
Автор

The expression iSquare = (iRow/3)*3+(iCol/3) will, for any column index and row index, yield a value 0..8 (a unique index for each 3x3 square)
... we can then use a bitmap of the values (1<<digit) to solve the problem with only 'logical OR' and 'logical AND', like so :

for(int y=0;y<9;y++) {
for(int x=0;x<9;x++) {
int s=(y/3)*3+(x*3);
int bit = 1<<Grid[y][x]; // Turns this digit into a unique positional bit from (digit 9) to (digit 1)
R[y] |= bit; //
C[x] |= bit; // aggregate all these bits to each 'column, row and square' they belong to.
S[s] |= bit; //
}
}
// For a correct sudoku this will yield the value 0x03FE (all values present 1..9) in all 9 elements of R[..], C[..] and S[..]
// We can check this by simply ANDing them all together...

int check = 0x03FE; // set all the bits we want to find
for(int i=0;i<9;i++) check &= C[i] & R[i] & S[i]; // Keeps only those bits that are set in every array

return (check == 0x03FE); // If 'check' still equals 0x3FE then bits 1..9 (ignoring bit 0) were set in every row column and square (so return true) else (return false)


Or you could use: bit = 1<< (Grid[y][x] - 1) to shift the '1' by 0..8 instead of by 1..9 ... and check the result against the value 0x01FF
_(which may be clearer to understand as it sets the 9 least significant bits, rather than leaving bit 0 unused. I probably should have done that. Oh well, LOL)_

garychap
visit shbcf.ru