implement problem, could be more elegant
refer to others' algorithm, still not figure out why, TODO
data structure problem, a little trival but good