Simple Easy C || C++ || Java Solution -- beats 100%
Intuition\n\nC++ []\nclass Solution {\npublic:\n    vector<int> separateDigits(vector<int>& nums) {\n        vector<int> ans;\n        vector<int> nums1;\n     
# Intuition\n![Screenshot 2024-02-01 124750.png](https://assets.leetcode.com/users/images/a60a2158-b015-4cd9-990a-57f54dbf2d45_1706771967.1229565.png)\n```C++ []\nclass Solution {\npublic:\n    vector<int> separateDigits(vector<int>& nums) {\n        vector<int> ans;\n        vector<int> nums1;\n        for (int i = 0; i < nums.size(); i++) {\n            int numm = nums[i];\n            int rev = 0;\n            while (numm != 0) {\n                int rem = numm % 10;\n                rev = rev * 10 + rem;\n                numm = numm / 10;\n            }\n            nums1.push_back(rev);\n        }\n        for (int i = 0; i < nums1.size(); i++) {\n            while (nums1[i] != 0) {\n                int rem = nums1[i] % 10;\n                ans.push_back(rem);\n                nums1[i] = nums1[i] / 10;\n            }\n            while (nums[i] % 10 == 0) {\n                ans.push_back(0);\n                nums[i] = nums[i] / 10;\n            }\n        }\n        return ans;\n    }\n};\n```\n```Java []\nclass Solution {\n    public int[] separateDigits(int[] nums) {\n        List<Integer> finalList = new ArrayList<Integer>();\n        for (int I : nums) {\n            List<Integer> currList = new ArrayList<Integer>();\n            for (int tempNum = I; tempNum > 0; tempNum /= 10)\n                currList.add(tempNum % 10);\n            for (int idx = currList.size() - 1; idx >= 0; idx--)\n                finalList.add(currList.get(idx));\n\n        }\n        int[] finalArray = new int[finalList.size()];\n        int idx = 0;\n        for (Integer I : finalList) {\n            finalArray[idx++] = (int) I;\n        }\n        return finalArray;\n    }\n}\n```\n```C []\n/**\n * Note: The returned array must be malloced, assume caller calls free().\n */\nint* separateDigits(int* nums, int numsSize, int* returnSize) {\n    int size = 0, temp, i, sum = 0;\n    for (i = 0; i < numsSize; i++) {\n        temp = nums[i];\n        while (temp) {\n            size += 1;\n            temp /= 10;\n        }\n    }\n    int* arr = malloc(sizeof(int) * size + 1);\n    *returnSize = size;\n    i = numsSize - 1;\n    temp = size - 1;\n    while (i >= 0) {\n        while (nums[i]) {\n            arr[temp--] = nums[i] % 10;\n            nums[i] /= 10;\n        }\n        i--;\n    }\n\n    return arr;\n}\n```\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n     O(n)\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n    O(n)\n# Code\n```\n/**\n * Note: The returned array must be malloced, assume caller calls free().\n */\nint* separateDigits(int* nums, int numsSize, int* returnSize) {\n    int size = 0, temp, i, sum = 0;\n    for (i = 0; i < numsSize; i++) {\n        temp = nums[i];\n        while (temp) {\n            size += 1;\n            temp /= 10;\n        }\n    }\n    int* arr = malloc(sizeof(int) * size + 1);\n    *returnSize = size;\n    i = numsSize - 1;\n    temp = size - 1;\n    while (i >= 0) {\n        while (nums[i]) {\n            arr[temp--] = nums[i] % 10;\n            nums[i] /= 10;\n        }\n        i--;\n    }\n\n    return arr;\n}\n```\n# Please upvote my solution for my efforts  . thanks\n![th.jpeg](https://assets.leetcode.com/users/images/44829d4a-0311-4d4c-914c-ec391822a195_1706772173.6476448.jpeg)\n
['C']