-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
2553_Separate_the_Digits_in_an_Array.cpp (#78)
* Contributed by @ritikraj018
- Loading branch information
1 parent
b369d12
commit 92c80f9
Showing
1 changed file
with
19 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
}; |