classSolution { public: boolisDivisor(string a, int num){ // string to int int n = 0; for(char c:a) n= 10*n+(c-'0'); // cout<<a<<"\t"<<n<<endl; if(n==0) returnfalse; elsereturn num%n==0; } intdivisorSubstrings(int num, int k){ // sliding window to get all substring which size is k int count = 0 ; // int convert to string string strs; int x = num; while(x) { strs+=to_string(x%10); x/=10; } reverse(strs.begin(), strs.end()); // cout<<strs<<endl; for(int i=k-1;i<strs.size();++i){ string tmp = strs.substr(i-k+1, k); if(isDivisor(tmp, num)) count++; } return count; } };