Maximum Palindromes

  • + 1 comment

    the part I don't like Hackerrank is that some problem is like a min math-oplymiad – in case you don't know the math concept/formula behind you cannot get the solution right even if you got the right idea/thought about how to solve.

    For example, this problem comes down to count how many permutations are there for the left half of palindrome (and then times that by number of odd chars) – and the answer is the multinomial (n, k).

    Anyway I got the code right, but cannot think of why it still got "time exceeded" – the multinomial calculation should be minimal, I'm not using factor(n) at atll. would appreciate if some big-shot in math can point out how to further improve

    n res //= i n -= 1 return res