Short Palindrome Discussions | Algorithms | HackerRank
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 agree that this is not a medium problem. After much messing around, I finally managed to get in running on Python with no timeouts. Even with an O(n) time and O(1) space algorithm, Python can be limiting just based on lookup times and aritmetic operation time. If you are close but can't quite make it without timeouts, try PyPy (I was able to use the code I wrote for Python 3 without alteration). Also, in a similar vein list calls seem to be much more efficient than dictionary calls in PyPy (unlike Python where I found them to be similar) which is important for an algorithm where elements are accessed so often.
Short Palindrome
You are viewing a single comment's thread. Return to all comments →
I agree that this is not a medium problem. After much messing around, I finally managed to get in running on Python with no timeouts. Even with an O(n) time and O(1) space algorithm, Python can be limiting just based on lookup times and aritmetic operation time. If you are close but can't quite make it without timeouts, try PyPy (I was able to use the code I wrote for Python 3 without alteration). Also, in a similar vein list calls seem to be much more efficient than dictionary calls in PyPy (unlike Python where I found them to be similar) which is important for an algorithm where elements are accessed so often.