1
# Runtime: 17 ms (Top 24.0%) | Memory: 13.24 MB (Top 48.1%)
2

3

4
class Solution(object):
5
def thousandSeparator(self, n):
6
"""
7
:type n: int
8
:rtype: str
9
"""
10
n = str(n)
11
if len(n) <= 3:
12
return str(n)
13
result = ""
14
dot = "."
15
index = 0
16
startPos = len(n) % 3
17
if startPos == 0:
18
startPos += 3
19
val = -1
20
while index < len(n):
21
result += n[index]
22
if index == startPos - 1:
23
result += dot
24
val = 0
25
if val != -1:
26
val += 1
27
if val > 3 and (val - 1) % 3 == 0 and index != len(n) - 1:
28
result += dot
29
val = 1
30
index += 1
31

32
return result

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0