-
Notifications
You must be signed in to change notification settings - Fork 37
LeetCode Solutions💡in Python3🐍 and C++
SamirPaulb/LeetCode
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Sorry, we had to truncate this directory to 1,000 files. 177 entries were omitted from the list. | ||||
Repository files navigation
class Solution(object): def licenseKeyFormatting(self, S, K): """ :type S: str :type K: int :rtype: str """ # https://leetcode.com/problems/license-key-formatting/discuss/96497/Python-solution S = S.upper().replace('-', '') ls = len(S) if ls % K == 0: pos = K else: pos = ls % K res = S[:pos] while pos < ls: res += '-' + S[pos:pos + K] pos += K return res
About
LeetCode Solutions💡in Python3🐍 and C++
Topics
Stars
Watchers
Forks
Packages 0
No packages published