HackerRank in a String!

  • + 0 comments

    Python solution:

    def hackerrankInString(s):
        # Write your code here
        compare_to = "hackerrank"
        input_word = [] 
        index = 0
        for c in s:
            if len(input_word) != len(compare_to):  
                if c == compare_to[index]:
                    input_word.append(c)
                    index += 1
        if "".join(input_word) == compare_to:
            return "YES"
        else:
            return "NO"