3 lines readable Python Solution


  • 0
    A
    class Solution(object):
        def licenseKeyFormatting(self, S, K):
            """
            :type S: str
            :type K: int
            :rtype: str
            """
            S = ''.join(S.split('-')).upper()[::-1]
            res = '-'.join(S[i:i+K] for i in range(0,len(S),K))[::-1]
            return res
    

Log in to reply
 

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