easy implementation problem, but spend too much time, also the code can be more elegant
another algorithm, no obvious advantage