Is there any elegant solution for this with bit-manipulation?
Please share.
Is there any elegant solution for this with bit-manipulation?
Please share.
This is my solution:
class Solution {
bool containsZero(int x)
{
while(x)
{
if(!(x%10))
return true;
x/=10;
}
return false;
}
public:
vector<int> getNoZeroIntegers(int n) {
int a = 1, b = n - 1;
while(containsZero(a) || containsZero(b))
{
a++; b--;
}
return vector<int> {a, b};
}
};
I got 0ms submission and faster than 100% of the submissions, so I don’t think there a faster solution with bit manipulation. If you find something better do let us know!