1006. Clumsy Factorial

Description

Here

Intuition

Check Solution 2, Improve to O(1)

里面有个技巧helper((N - 2) % 4 + 2)

0 -> 0
1 -> 1
2 -> 2
3 -> 3
4 -> 4
5 -> 5
6 -> 2
7 -> 3

转化成从5开始的,4个一循环

Pitfall

Solution

results matching ""

    No results matching ""