add 9Z's solution. Very compact or clear. Memorize it.