LeetCode solutions

1660. Thousand Separator

My accepted Python solution to LeetCode problem 1660, Thousand Separator, running in 0ms.

  • Difficulty: Easy
  • Python
  • Runtime 0ms
  • Memory 17.4MB

Read the problem on LeetCode View on GitHub

Python

Accepted on LeetCode — runtime 0ms, memory 17.4MB, accepted 2025-12-30.

python
class Solution:
    def thousandSeparator(self, n: int) -> str:
        s = str(n)
        result = []
        for i, c in enumerate(reversed(s)):
            if i > 0 and i % 3 == 0:
                result.append('.')
            result.append(c)
        return ''.join(reversed(result))

Source