I have tried that proposed solution in #5, it failed one of the test case.
Up...