Switchfully interview question

Explaining your pseudocode and explain your reasoning