Calculate number of ways to arrange remaining N - 2 digits
cur_ans = Fact [ N - 2 ] ; for ( let k = 0 ; k <= 9 ; k ++ ) { cur_ans = Math . floor ( cur_ans / Fact [ freq [ k ] ] ) ; } ans = ans + cur_ans ;