CarlosLabs
Hackerrank Challenges - Hackerrank in a String
(CM) Part of the solution can be gleaned by reading the problem description in Hackerrank.
def hackerrankInString(s): # array to check against p = [['h','a','c','k','e','r','r','a','n','k'], [-1,-1,-1,-1,-1,-1,-1,-1,-1,-1]] retVal="NO" startP=0 startS=0 endP=len(p[0]) endS=len(s) prevCheck=0 if (len(s) < len(p[0])): return retVal s = s.lower() for ch in range(startS,endS): thisCharS=s[ch] thisCharP=p[0][startP] if (thisCharS==thisCharP) and ((p[1][startP])==(-1)): #print('match: ' + thisCharP) p[1][startP]=ch startP+=1 if (startP >= endP): break if (p[1][0]