Convert Integer to the Sum of Two No-Zero Integers LeetCode solution in C++

1
class Solution {
2
public:
3
int has0(int x) {
4
while (x) {
5
if (x % 10 == 0) return 1;
6
x /= 10;
7
}
8
return 0;
9
}
10
vector<int> getNoZeroIntegers(int n) {
11
for (int i = 1; i <= n; i++) {
12
if (has0(i) == false && has0(n - i) == false) {
13
return {i, n - i};
14
}
15
}
16
return {1, 1};
17
}
18
};

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0