Skip to content

Latest commit

 

History

History
24 lines (15 loc) · 373 Bytes

482.md

File metadata and controls

24 lines (15 loc) · 373 Bytes

482 License Key Formatting

Description

link


Solution

  • See Code

Code

O(n) O(1)

class Solution:
    def licenseKeyFormatting(self, S: str, K: int) -> str:
        S = S.replace("-", "").upper()[::-1]
        return '-'.join(S[i:i+K] for i in range(0, len(S), K))[::-1]