본문 바로가기
python-algorithm

leetcode 2553. Separate the Digits in an Array

by 무적김두칠 2023. 3. 14.

https://leetcode.com/problems/separate-the-digits-in-an-array/description/

 

Separate the Digits in an Array - LeetCode

Can you solve this real interview question? Separate the Digits in an Array - Given an array of positive integers nums, return an array answer that consists of the digits of each integer in nums after separating them in the same order they appear in nums.

leetcode.com

 

1
2
3
4
5
6
7
8
class Solution:
    def separateDigits(self, nums: List[int]) -> List[int]:
        answer = []
        for num in nums:
            for one_num in str(num):
                answer.append(int(one_num))
 
        return answer
cs
반응형

댓글