Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add solutions to lc problem: No.3032 #2331

Merged
merged 13 commits into from
Feb 10, 2024
Merged
Next Next commit
feat: add solutions to lc problem: No.3032
  • Loading branch information
Nothing-avil authored Feb 9, 2024
commit ace7f9bc73504200b104a3e1799bc2bae5f18de2
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
class Solution {
public:
bool isvalid(int n) {
vector<bool> present(10, false);
while (n) {
const int dig = n % 10;
if (present[dig])
return false;
present[dig] = true;
n /= 10;
}
return true;
}
int numberCount(int a, int b) {
int res = 0;
for (int i = a; i <= b; ++i)
if (isvalid(i)){
++res;
}
return res;
}
};