Skip to content

Commit

Permalink
2553_Separate_the_Digits_in_an_Array.cpp (#78)
Browse files Browse the repository at this point in the history
* Contributed by @ritikraj018
  • Loading branch information
ritikraj018 authored Feb 16, 2023
1 parent b369d12 commit 92c80f9
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions cpp/2553_Separate_the_Digits_in_an_Array.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
class Solution {
public:
vector<int> separateDigits(vector<int>& nums) {
vector<int> answer;
int n;
for( int i=0; i < nums.size(); i++){
n=nums[i];
vector<int> temp;
while( n>0 ){
temp.push_back(n%10);
n = n / 10;
}
for(int j= temp.size()-1; j>=0; j--){
answer.push_back(temp[j]);
}
}
return answer;
}
};

0 comments on commit 92c80f9

Please sign in to comment.