Separate the Digits in an Array - Problem
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.
To separate the digits of an integer is to get all the digits it has in the same order.
For example, for the integer 10921, the separation of its digits is [1,0,9,2,1].
Input & Output
Example 1 — Basic Case
$
Input:
nums = [13,25,83]
›
Output:
[1,3,2,5,8,3]
💡 Note:
Separate digits: 13 → [1,3], 25 → [2,5], 83 → [8,3]. Combine: [1,3,2,5,8,3]
Example 2 — Single Digits
$
Input:
nums = [7,1,3,9]
›
Output:
[7,1,3,9]
💡 Note:
Single digit numbers remain unchanged: [7,1,3,9]
Example 3 — Larger Numbers
$
Input:
nums = [1000,23]
›
Output:
[1,0,0,0,2,3]
💡 Note:
1000 → [1,0,0,0], 23 → [2,3]. Combined: [1,0,0,0,2,3]
Constraints
- 1 ≤ nums.length ≤ 1000
- 1 ≤ nums[i] ≤ 105
Visualization
Tap to expand
Understanding the Visualization
1
Input Array
Array of positive integers
2
Separate Digits
Extract each digit from every number
3
Output Array
Flattened array of individual digits
Key Takeaway
🎯 Key Insight: Convert each number to string or use mathematical operations to extract digits in order
💡
Explanation
AI Ready
💡 Suggestion
Tab
to accept
Esc
to dismiss
// Output will appear here after running code