4039. Compute Decimal Representation
My accepted Python solution to LeetCode problem 4039, Compute Decimal Representation, running in 3ms.
- Difficulty: Easy
- Python
- Runtime 3ms
- Memory 17.3MB
- Updated
Read the problem on LeetCode View on GitHub
The problem statement is LeetCode’s and stays on their site. What follows is my accepted solution.
Python
Accepted on LeetCode — runtime 3ms, memory 17.3MB, accepted 2025-12-30.
class Solution:
def decimalRepresentation(self, n: int) -> List[int]:
result = []
multiplier = 1
while n > 0:
digit = n % 10
if digit != 0:
result.append(digit * multiplier)
n //= 10
multiplier *= 10
return result[::-1] # Descending order