Monday, October 4, 2010

String Rotation..

Given two strings s1, s2 check if s1 is a rotated version of s2 ?

Came across a neat solution via stackoverflow..


algorithm checkRotation(string s1, string s2)
if( len(s1) != len(s2))
return false
if( substring(s2,concat(s1,s1))
return true
return false
end

No comments: