forked from SamirPaulb/LeetCode
-
Notifications
You must be signed in to change notification settings - Fork 0
LeetCode Solutions💡in Python3🐍 and C++
License
VLSILab/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++
License
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published
Languages
- Python 78.0%
- C++ 18.3%
- HTML 2.7%
- Other 1.0%