Block interview question

TO provide an algorithm