Nestlé interview question

Regarding the chosen function’s issue