Solved problem 8.
Applied as-pattern to make code simple.
Solved problem 9.
Fixed a bug of duplicate of the last element.
Solved problem 10.