design an algorithm to encode a list of strings to a string the encoded mystring is then sent over the network and is decoded back to the original list of strings implement the encode and decode methods encodes a list of strings to a single string type strs liststr rtype str decodes a single string to a list of strings type s str rtype liststr implement the encode and decode methods encodes a list of strings to a single string type strs list str rtype str decodes a single string to a list of strings type s str rtype list str
def encode(strs):
    
    res = ''
    for string in strs.split():
        res += str(len(string)) + ":" + string
    return res

def decode(s):
    
    strs = []
    i = 0
    while i < len(s):
        index = s.find(":", i)
        size = int(s[i:index])
        strs.append(s[index+1: index+1+size])
        i = index+1+size
    return strs