Skip to content

Instantly share code, notes, and snippets.

@dudepare
dudepare / rotation.py
Created August 26, 2016 05:14
String Rotation: Assumeyou have a method isSubstringwhich checks ifoneword isa substring of another. Given two strings, sl and s2, write code to check if s2 is a rotation of sl using only one call to isSubstring (e.g., "waterbottle" is a rotation of"erbottlewat").
class Rotation:
@staticmethod
def is_substring(s1, s2):
"""Checks if s2 is a substring of s1
Args:
s1 (string) string input
s2 (string) rotation of s1