Tried solving 149 E Martian Strings using z-algo. my approach is: compute z index for pattern$text and reverse(pattern)$reverse(text). then find the minimum index for each prefix length match and find the maximum suffix length match indexes for all i (0<=i<length(pattern). the complexity of my code is approx O(m*n). getting TLE. tried optimizing a lot but no luck till now, also tried reading others code but could make sense out of those. my code: submission link