Java Competitive Coding 02: HackerRank Magic Squares Challenge

preview_player
Показать описание
In this video, I show you my solution to the HackerRank Magic Squares Challenge. I hope to continue to get better at these challenging problems and improve my solutions to be more efficient!

Thank you guys for watching! :D

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

Beautiful solution! I like the % approach, splitting in 3-s

deleted-ug
Автор

Thank you. I had been stuck with this problem for a week and quit HackerRank for a few months and now I can continue.

noahjung
Автор

Great! But I would use a list of 2D arrays. That way you can find the cost simply by getting the same positions like: s[i][k] - squares[i][j]

danielsampedro
Автор

I don't like this type of problem, I prefer problems that you can come up with a resolution using only the information provided and reasoning. If a person never heard of magic squares, even if this person has a high IQ, he/she would take a long time to figure out these 8 possibilities. I guess almost no one could come up if these 8 magic squares intuitively using only reasoning. At Hackerrank this problem has a success rate of 77%, either they are all genius, or they at least look up the 8 magic squares on the internet. :P

dan
Автор

Thank you for the hack, but how would you approach this without the copying that you did, like in a test situation?

smanqele
Автор

Can this only be solved by manually solving the magic square beforehand and stashing it as data? What if it was a 4x4 or a 9x9 square, how would you compute the target value each row, column, diagonal would need to equate?

Also, may I suggest you access your 2D-arrays in a consistent manner? Viewers are here to grasp the logic of the problem and thought process to solving it and don't need to be distracted by coding styles

philipthomas
Автор

Hey! Great work man you should continue making videos.

DEEPAKKUMAR-xevb
Автор

you should have given that square array in the description so that i can copy 😂

relaxwithmusic
Автор

Explanation is good but stop putting useless background tunes

PulkitMalhotra