XinAo Gas interview question

Two questions about algorithm question?