We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 2f3fe71 commit 41c1b30Copy full SHA for 41c1b30
solution/0728.Self Dividing Numbers/Solution.cpp
@@ -0,0 +1,33 @@
1
+class Solution {
2
+ public:
3
+ int div(int num){
4
+
5
+ int temp = num, r;
6
7
+ while( temp > 0 ){
8
9
+ r = temp % 10;
10
11
+ if( r == 0 || num % r != 0){
12
+ return 0;
13
+ }
14
15
+ temp /= 10;
16
17
18
+ return 1;
19
20
21
+ vector<int> selfDividingNumbers(int left, int right) {
22
23
+ vector<int> ret;
24
25
+ for(int i = left; i <= right; i++){
26
+ if( div(i) ){
27
+ ret.push_back(i);
28
29
30
31
+ return ret;
32
33
+};
0 commit comments