Created
August 4, 2016 20:50
-
-
Save kigold/34fc0107d14a79f5b8064c9b44651053 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def chkSqe(a1, a2): | |
''' | |
this method receive two array on characters, a1, and a2 | |
it checks array a1 is the sequence of character in a2 exist | |
in the order, and returns true is so, or false if not | |
Args: a1: array of characters | |
a2: array of characters | |
Return: Boolean | |
''' | |
char_to_chk = 0 | |
for i in range(len(a1)): | |
#check if the length of a1 remaining is more than the length of | |
#the remaining sequence | |
if (len(a2) - char_to_chk) > len(a1[i:]): | |
break | |
if a1[i] == a2[char_to_chk]: | |
if char_to_chk == len(a2) - 1: | |
return True | |
if char_to_chk + 1 < len(a2): | |
char_to_chk += 1 | |
continue | |
else: | |
char_to_chk = 0 | |
return False |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment