Dirty and evil solution in Python (3 lines)


  • 1
    L
    class Codec:
        
        boundry = "-1-2-3-4-3-2-1-"
    
        def encode(self, strs):
            """Encodes a list of strings to a single string.
            
            :type strs: List[str]
            :rtype: str
            """
            return "".join([s + self.boundry for s in strs])
    
        def decode(self, s):
            """Decodes a single string to a list of strings.
            
            :type s: str
            :rtype: List[str]
            """
            return s.split(self.boundry)[:-1]
    

    You are here!
    Your runtime beats 100.00% of python submissions.


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.