Lanvera interview question

For loop logic using if conditions