Skip to content

Commit d07e9a9

Browse files
add 3032
1 parent 1af29b4 commit d07e9a9

File tree

2 files changed

+30
-0
lines changed
  • paginated_contents/algorithms/4th_thousand
  • src/main/java/com/fishercoder/solutions/fourththousand

2 files changed

+30
-0
lines changed

Diff for: paginated_contents/algorithms/4th_thousand/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@
6262
| 3042 | [Count Prefix and Suffix Pairs I](https://leetcode.com/problems/count-prefix-and-suffix-pairs-i/) | [Java](https://github.com/fishercoder1534/Leetcode/blob/master/src/main/java/com/fishercoder/solutions/fourththousand/_3042.java) | | Easy |
6363
| 3038 | [Maximum Number of Operations With the Same Score I](https://leetcode.com/problems/maximum-number-of-operations-with-the-same-score-i/) | [Java](https://github.com/fishercoder1534/Leetcode/blob/master/src/main/java/com/fishercoder/solutions/fourththousand/_3038.java) | | Easy |
6464
| 3033 | [Modify the Matrix](https://leetcode.com/problems/modify-the-matrix/) | [Java](https://github.com/fishercoder1534/Leetcode/blob/master/src/main/java/com/fishercoder/solutions/fourththousand/_3033.java) | | Easy |
65+
| 3032 | [Count Numbers With Unique Digits II](https://leetcode.com/problems/count-numbers-with-unique-digits-ii/) | [Java](https://github.com/fishercoder1534/Leetcode/blob/master/src/main/java/com/fishercoder/solutions/fourththousand/_3032.java) | | Easy |
6566
| 3010 | [Divide an Array Into Subarrays With Minimum Cost I](https://leetcode.com/problems/divide-an-array-into-subarrays-with-minimum-cost-i/) | [Java](https://github.com/fishercoder1534/Leetcode/blob/master/src/main/java/com/fishercoder/solutions/fourththousand/_3010.java) | | Easy |
6667
| 3014 | [Minimum Number of Pushes to Type Word I](https://leetcode.com/problems/minimum-number-of-pushes-to-type-word-i/) | [Java](https://github.com/fishercoder1534/Leetcode/blob/master/src/main/java/com/fishercoder/solutions/fourththousand/_3014.java) | | Easy |
6768
| 3006 | [Find Beautiful Indices in the Given Array I](https://leetcode.com/problems/find-beautiful-indices-in-the-given-array-i/) | [Java](https://github.com/fishercoder1534/Leetcode/blob/master/src/main/java/com/fishercoder/solutions/fourththousand/_3006.java) | | Medium |
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package com.fishercoder.solutions.fourththousand;
2+
3+
import java.util.HashSet;
4+
import java.util.Set;
5+
6+
public class _3032 {
7+
public static class Solution1 {
8+
public int numberCount(int a, int b) {
9+
int ans = 0;
10+
for (int num = a; num <= b; num++) {
11+
if (isUniqeDigits(num)) {
12+
ans++;
13+
}
14+
}
15+
return ans;
16+
}
17+
18+
private boolean isUniqeDigits(int num) {
19+
Set<Integer> seen = new HashSet<>();
20+
while (num != 0) {
21+
if (!seen.add(num % 10)) {
22+
return false;
23+
}
24+
num /= 10;
25+
}
26+
return true;
27+
}
28+
}
29+
}

0 commit comments

Comments
 (0)