We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Anti-Palindromic Strings
Anti-Palindromic Strings
Sort by
recency
|
46 Discussions
|
Please Login in order to post a comment
C# one-line
..without BigInteger would be longer :)
Here's my solution in JAVA:
C++
Since this problem requires processing of integers exceeding 2^64, I would not recommend attemping to solve it using a language that does not provide support for "big integers", eg use Java or C# and not Javascript. Also, note that in order to meet execution time constraints you need to use a modular exponentiation algorithm such as that provided by Java's BigInt.modPow() to compute (N - 2)^(M - 2), otherwise some tests will time out. Finally note that the output must be displayed modulo 1000000007 (shown cryptically as "10^9 + 7" in the problem text). I mention these things because it seems clear from the discussions that many submitters missed these issues due to lack of clarity in the problem statement.
To the HR folks I suggest reviewing the challenge desciptions for clarity and completeness. Given that employers use your system to evaluate job candidates it is important that the descriptions be clearly presented and IMHO many of them are not. Here are some suggestions for improving clarity:
In case if you are trying to do it in a DP fashion to calculate the amount of length(n-1) with set cardinality of m, don't do it ... It won't work. :/