Kry interview question

Basically explaining the code I did