Hackerrank test problem

Revision en1, by search_fool, 2020-12-20 16:52:52

Hi community. I was giving test for some hiring problem. The problem says given an array of size N and numbers from 1...M find number of ways to create the array with the followings restrictions. 1) a[i]≠a[i+1] 2) a[1]=a[N] (1 based index) Constraints 3<=N,M<=10^18 I was came up with formula M*(M-1)^(N-3) (M-2) n>3 and M(M-1) n==3 But it gave WA. Any suggestions. Thankyou in advance.

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en3 English search_fool 2020-12-20 16:57:19 1 Tiny change: 'M-1)^(N-3) *(M-2) n>' -> 'M-1)^(N-3)*(M-2) n>'
en2 English search_fool 2020-12-20 16:53:39 9 Tiny change: 'me hiring problem. The prob' -> 'me hiring test. The prob'
en1 English search_fool 2020-12-20 16:52:52 428 Initial revision (published)