private static int solution(int n) { int[] dp = new int[n+1]; dp [2] = 1; for (int i = 3; i<=n;i++) { dp [i] = (i-1)*( dp [i-1]+ dp [i-2]); } return dp [n]; }