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.
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:
clealy written with correct grammar
use mnemonics for inputs, eg phraseLengh and maxCharacters instead of M and N
list execution time constraints if problem is performance oriented
complete examples, eg in this problem a segmentLength of four would have clarified the "any palidrome" concept
express constants in standard form, eg 1000000007 and not 10^9 + 7.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Anti-Palindromic Strings
You are viewing a single comment's thread. Return to all comments →
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: