HTMLify

LeetCode - Separate the Digits in an Array - Python
Views: 142 | Author: abh
class Solution:
    def separateDigits(self, nums: List[int]) -> List[int]:
        saprated = []
        for num in nums:
            if isinstance(num, list):
                saprated.append(Solution.separateDigits(num))
            else:
                digits = []
                while num:
                    digits.append(num%10)
                    num //= 10
                for d in digits[::-1]:
                    saprated.append(d)
        return saprated

Comments