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.
- Prepare
- Algorithms
- Search
- Short Palindrome
- Discussions
Short Palindrome
Short Palindrome
Sort by
recency
|
65 Discussions
|
Please Login in order to post a comment
inline int I(const char i){return i-'a';} // convert character into index 'a'=0 ..
inline void SUM(long & s,long & x){s = (s + x)% 1000000007;} // add x into s with modulo
int shortPalindrome(string s) {
}
Python 3 solution
This problem is similar to Count Triplets
import string
from collections import defaultdict
def shortPalindrome(s): # Write your code here
standard dynamic programming algo, O(n), but uses a lot of memory (couple hundred MBs). pass all test
C++ (more at https://github.com/IhorVodko/Hackerrank_solutions , feel free to give a star :) )