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.
cant improve the recursion in the below code ... gives timeout error.....
main = do
n<-readLn
fn n []
fn n rs = do
if n>0 then do
s1<-getLine
s2<-getLine
fn (n-1) (rs++[(s1,s2)])
else do
let x = process rs
putStrLn x
f' str sstr = f str sstr str sstr
f [] _ _ _ = "YES"
f _ [] _ _ = "NO"
f (x:xs) (y:ys) gs ls = if x==y then f xs ys gs ls else f gs (drop 1 ls) gs (drop 1 ls)
process xs = unlines $ map ((x,y)->(f' y x)) xs
Substring Searching
You are viewing a single comment's thread. Return to all comments →
cant improve the recursion in the below code ... gives timeout error.....