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 would like to comment to the post below by abulatovic. I solved this problem a few minutes ago, and I agree, it is not an easy one, but from my perspective, the challenge is mostly in getting all the border cases right. I did not use a "maxheap" or a "maxsegment tree" (I do not even know what they are, but I did not use any trees). In my first two submissions, which did not pass all test cases, it was never that I ran into timeouts, but rather either wrong answers (due to some mistakes in formulas) or segmentation faults (not checking things enough).
Anyway, do not get onto the wrong track - the problem is well solvable. Obviously you cannot traverse the string again for every rotation, or effectively rotate the string without running into performance problems.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Circular Palindromes
You are viewing a single comment's thread. Return to all comments →
I would like to comment to the post below by abulatovic. I solved this problem a few minutes ago, and I agree, it is not an easy one, but from my perspective, the challenge is mostly in getting all the border cases right. I did not use a "maxheap" or a "maxsegment tree" (I do not even know what they are, but I did not use any trees). In my first two submissions, which did not pass all test cases, it was never that I ran into timeouts, but rather either wrong answers (due to some mistakes in formulas) or segmentation faults (not checking things enough). Anyway, do not get onto the wrong track - the problem is well solvable. Obviously you cannot traverse the string again for every rotation, or effectively rotate the string without running into performance problems.