NetApp Interview Question
Software Engineer / DevelopersUsing python
str1 = 'abcd'
str2 = 'bcda'
l1 = list(str1)
l2 = list(str2)
is_found = False
for each in range(1, len(str1)):
l1 = [l1.pop()] + l1[:len(str1)-1]
if "".join(l1) == str2:
is_found = True
break
if is_found == True:
print ("{} and {} are same strings that can be rotated".format(str1, str2))
else:
print("not found")
Concatante the original string with itself and search for second string.
- ManishSindhi January 18, 2011using strstr()