BNY Interview Question

Runtime of the given algorithm