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.
I Wish To Register A Complaint... (With due respect to the classic Monty Python "Dead Parrot" sketch.)
I actually solved this problem in about ten minutes, because I had recently worked on the "Build A Palindrome" problem and I had at hand the code to build suffix arrays and lcp arrays.
But it failed on test cases 10 and 11. I quickly figured out that the result needed to be returned as a 64-bit integer, which meant that the stringSimilarity function (I work in C++) had to be defined as returning a 'long long'. And in my test code, it worked fine; I even spent the hackos to get case 10 and I verified I was getting it right.
But it still failed on the web site. I finally -- finally -- noticed that the boilerplate code in the main() function was converting my answer to a 32-bit int, and thus messing things up. When I changed that to a 'long long' (just 'long' would have worked, too; the hackerrank compiler has a 64-bit long, while my Microsoft environment requires 'long long') the problem went away.
In my opinion, the problem code provided by hackerrank should be changed from 'int' to 'long'. Some of these problems are plenty tough without having to debug the code provided by the test environment.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
String Similarity
You are viewing a single comment's thread. Return to all comments →
I Wish To Register A Complaint... (With due respect to the classic Monty Python "Dead Parrot" sketch.)
I actually solved this problem in about ten minutes, because I had recently worked on the "Build A Palindrome" problem and I had at hand the code to build suffix arrays and lcp arrays.
But it failed on test cases 10 and 11. I quickly figured out that the result needed to be returned as a 64-bit integer, which meant that the stringSimilarity function (I work in C++) had to be defined as returning a 'long long'. And in my test code, it worked fine; I even spent the hackos to get case 10 and I verified I was getting it right.
But it still failed on the web site. I finally -- finally -- noticed that the boilerplate code in the main() function was converting my answer to a 32-bit int, and thus messing things up. When I changed that to a 'long long' (just 'long' would have worked, too; the hackerrank compiler has a 64-bit long, while my Microsoft environment requires 'long long') the problem went away.
In my opinion, the problem code provided by hackerrank should be changed from 'int' to 'long'. Some of these problems are plenty tough without having to debug the code provided by the test environment.