Posted on

Description

Submission

class Solution {
    bool check(int n) {
        int t = n;
        for(; t; t /= 10) {
            int r = t % 10;
            if(r == 0 || n % r != 0) return false;
        }
        return true;
    }
public:
    vector<int> selfDividingNumbers(int left, int right) {
        vector<int> rets;
        for(int i = left; i <= right; ++i) {
            if(check(i)) rets.push_back(i);
        }
        return rets;
    }
};

Leave a Reply

Your email address will not be published. Required fields are marked *