Quest Global interview question

Simple algorithm and basics.