Best Solution in Java and Easy and Understandable Code in Java
Intuition\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 
# Intuition\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\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\n    public static int[] separateDigits(int[] nums) \n    {\n        ArrayList<Integer> list = new ArrayList<Integer>();\n        // ArrayList<Integer> list1 = new ArrayList<Integer>();\n        for(int i=0; i<nums.length;i++)\n        {\n            if(nums[i]<10)\n            {\n                list.add(nums[i]);\n            }\n            else\n            {\n                String s = Integer.toString(nums[i]);\n                for(int j=0; j<s.length(); j++)\n                {\n                    int n = Integer.parseInt(String.valueOf(s.charAt(j)));\n                    list.add(n);\n                }\n            }\n\n        }\n        int ans[] = new int[list.size()];\n        for(int i=0; i<list.size();i++)\n        {\n            ans[i] = list.get(i);\n        }\n        return ans;\n        \n    }\n}\n```
['Java']