Google interview question

create an algorithm for a problem, optimize it, O - notation