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 |
반응형
'python-algorithm' 카테고리의 다른 글
leetcode 2348. Number of Zero-Filled Subarrays (0) | 2023.03.21 |
---|---|
leetcode 1009. Complement of Base 10 Integer (0) | 2023.03.20 |
leetcode 1122. Relative Sort Array (0) | 2023.03.13 |
leetcode 2395. Find Subarrays With Equal Sum (0) | 2023.03.13 |
백준 27866 문자와 문자열 (0) | 2023.03.13 |
댓글