XinAo Gas Interview Question

Two questions about algorithm question?