BNY interview question

Runtime of the given algorithm