@AlexanderPetrov First, comments are for "getting additional information or suggesting improvements", none of which yours are addressing (at best, they're half-baked attempts to validate and defend a
very poor selection of code); second, you really
should be more humble,
you are the one asking why this code was rejected from an interview, it's not wise to take every person's attempt at explaining that and point out "flaws" (which, let's be honest, they're not really flaws). If this is a pride thing, just understand that
all programmers suck at some point,
this is where we get better. —
EBrown 5 secs ago