Block interview question

solve a leetcode coding problem.