Skip to content

Commit 843dd20

Browse files
add 2729
1 parent 4b00230 commit 843dd20

File tree

3 files changed

+46
-0
lines changed
  • paginated_contents/algorithms/3rd_thousand
  • src

3 files changed

+46
-0
lines changed

Diff for: paginated_contents/algorithms/3rd_thousand/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
| 2744 | [Find Maximum Number of String Pairs](https://leetcode.com/problems/find-maximum-number-of-string-pairs/) | [Java](https://github.com/fishercoder1534/Leetcode/blob/master/src/main/java/com/fishercoder/solutions/thirdthousand/_2744.java) | | Easy |
1818
| 2739 | [Total Distance Traveled](https://leetcode.com/problems/total-distance-traveled/) | [Java](https://github.com/fishercoder1534/Leetcode/blob/master/src/main/java/com/fishercoder/solutions/thirdthousand/_2739.java) | | Easy |
1919
| 2733 | [Neither Minimum nor Maximum](https://leetcode.com/problems/neither-minimum-nor-maximum/) | [Java](https://github.com/fishercoder1534/Leetcode/blob/master/src/main/java/com/fishercoder/solutions/thirdthousand/_2733.java) | | Easy |
20+
| 2729 | [Check if The Number is Fascinating](https://leetcode.com/problems/check-if-the-number-is-fascinating/) | [Java](https://github.com/fishercoder1534/Leetcode/blob/master/src/main/java/com/fishercoder/solutions/thirdthousand/_2729.java) | | Easy |
2021
| 2716 | [Minimize String Length](https://leetcode.com/problems/minimize-string-length/) | [Java](https://github.com/fishercoder1534/Leetcode/blob/master/src/main/java/com/fishercoder/solutions/thirdthousand/_2716.java) | [:tv:](https://youtu.be/aMJ3T0K8LjI) | Easy |
2122
| 2710 | [Remove Trailing Zeros From a String](https://leetcode.com/problems/remove-trailing-zeros-from-a-string/) | [Java](https://github.com/fishercoder1534/Leetcode/blob/master/src/main/java/com/fishercoder/solutions/thirdthousand/_2710.java) | | Easy |
2223
| 2706 | [Buy Two Chocolates](https://leetcode.com/problems/buy-two-chocolates/) | [Java](https://github.com/fishercoder1534/Leetcode/blob/master/src/main/java/com/fishercoder/solutions/thirdthousand/_2706.java) | | Easy |
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package com.fishercoder.solutions.thirdthousand;
2+
3+
import java.util.HashSet;
4+
import java.util.Set;
5+
6+
public class _2729 {
7+
public static class Solution1 {
8+
public boolean isFascinating(int n) {
9+
StringBuilder sb = new StringBuilder();
10+
sb.append(n);
11+
sb.append(n * 2);
12+
sb.append(n * 3);
13+
String num = sb.toString();
14+
Set<Integer> set = new HashSet<>();
15+
for (int i = 0; i < num.length(); i++) {
16+
if (num.charAt(i) == '0' || !set.add(Integer.parseInt(num.charAt(i) + ""))) {
17+
return false;
18+
}
19+
}
20+
return set.size() == 9;
21+
}
22+
}
23+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package com.fishercoder.thirdthousand;
2+
3+
import com.fishercoder.solutions.thirdthousand._2729;
4+
import org.junit.jupiter.api.BeforeEach;
5+
import org.junit.jupiter.api.Test;
6+
7+
import static org.junit.jupiter.api.Assertions.assertTrue;
8+
9+
public class _2729Test {
10+
private static _2729.Solution1 solution1;
11+
12+
@BeforeEach
13+
public void setup() {
14+
solution1 = new _2729.Solution1();
15+
}
16+
17+
@Test
18+
public void test1() {
19+
assertTrue(solution1.isFascinating(192));
20+
}
21+
22+
}

0 commit comments

Comments
 (0)