BJIT interview question

search algo with single loop