abhatter's blog

By abhatter, history, 3 years ago, In English

Hello, I am trying to generate all permutations and for each permutation I am checking if the given conditions are satisfied and then counting it as part of the solution. But this approach times out as the time complexity is n*n!

I am not able to understand as to what can be precomputed.

Any help is appreciated.

Click for problem link

Thanks in advance

  • Vote: I like it
  • +1
  • Vote: I do not like it