https://leetcode.com/problems/shortest-way-to-form-string/

class Solution:
    def shortestWay(self, s: str, t: str) -> int:
        count = 0
        rem = t
        while len(rem) > 0:
            i = 0
            j = 0
            substring = ''
            while i < len(s) and j < len(rem):
                if(s[i] == rem[j]):
                    substring += rem[j]
                    j+=1
                i +=1
            if(substring == ''):
                return -1
            count +=1
            rem = rem[len(substring):]  
        return count