forked from fishercoder1534/Leetcode
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path_2553.java
28 lines (26 loc) · 815 Bytes
/
_2553.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
package com.fishercoder.solutions;
import java.util.ArrayList;
import java.util.List;
public class _2553 {
public static class Solution1 {
public int[] separateDigits(int[] nums) {
List<Integer> list = new ArrayList<>();
for (int num : nums) {
List<Integer> thisList = new ArrayList<>();
while (num != 0) {
thisList.add(num % 10);
num /= 10;
}
for (int i = thisList.size() - 1; i >= 0; i--) {
list.add(thisList.get(i));
}
}
int[] result = new int[list.size()];
int i = 0;
for (int num : list) {
result[i++] = num;
}
return result;
}
}
}