add iterative solution for mindepth problem