Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 92c80f9

Browse files
authored
2553_Separate_the_Digits_in_an_Array.cpp (qiyuangong#78)
* Contributed by @ritikraj018
1 parent b369d12 commit 92c80f9

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
class Solution {
2+
public:
3+
vector<int> separateDigits(vector<int>& nums) {
4+
vector<int> answer;
5+
int n;
6+
for( int i=0; i < nums.size(); i++){
7+
n=nums[i];
8+
vector<int> temp;
9+
while( n>0 ){
10+
temp.push_back(n%10);
11+
n = n / 10;
12+
}
13+
for(int j= temp.size()-1; j>=0; j--){
14+
answer.push_back(temp[j]);
15+
}
16+
}
17+
return answer;
18+
}
19+
};

0 commit comments

Comments
 (0)