Expand Each Positive Integer into Its Ordered Decimal Digits

Quick Overview

Expand each positive array value into its decimal digits while preserving both number order and digit order.

Expand Each Positive Integer into Its Ordered Decimal Digits

Company: Google

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: easy

Interview Round: Other

### Problem Replace every positive number in `nums` by its decimal digits, from most significant to least significant. Concatenate these digit sequences in the original array order and return the resulting integer array. ```cpp class Solution { public: vector<int> separateDigits(vector<int>& nums); }; ``` ### Examples **Example 1:** ```text Input: nums = [20,105] Output: [2,0,1,0,5] Explanation: Internal zero digits are retained, and 20 precedes105. ``` **Example 2:** ```text Input: nums = [9,4] Output: [9,4] Explanation: Each one-digit number contributes itself. ``` ### Constraints - `1 <= nums.length <= 1000`. - `1 <= nums[i] <= 100000`. ### Clarifying Questions - Is the array order preserved? Yes. - Is each number's digit order preserved? Yes, from most significant to least significant. - Are internal zero digits kept? Yes. - Are padding zeroes added? No. ```hint Check the boundary Check a number containing an internal zero. ```

Overview: Expand each positive array value into its decimal digits while preserving both number order and digit order.

Google logo
Google
Source window: 0–6 months · as of Oct 21, 2026
easySoftware EngineerOtherCoding & Algorithms
0
0

Problem

Replace every positive number in nums by its decimal digits, from most significant to least significant. Concatenate these digit sequences in the original array order and return the resulting integer array.

class Solution {
public:
    vector<int> separateDigits(vector<int>& nums);
};

Examples

Example 1:

Input: nums = [20,105]
Output: [2,0,1,0,5]
Explanation: Internal zero digits are retained, and 20 precedes105.

Example 2:

Input: nums = [9,4]
Output: [9,4]
Explanation: Each one-digit number contributes itself.

Constraints

  • 1 <= nums.length <= 1000 .
  • 1 <= nums[i] <= 100000 .

Clarifying Questions Guidance

  • Is the array order preserved? Yes.
  • Is each number's digit order preserved? Yes, from most significant to least significant.
  • Are internal zero digits kept? Yes.
  • Are padding zeroes added? No.