Skip to content

Commit 9dc0047

Browse files
[LEET-3491] add 3491
1 parent 9db17c3 commit 9dc0047

File tree

3 files changed

+38
-0
lines changed
  • paginated_contents/algorithms/4th_thousand
  • src

3 files changed

+38
-0
lines changed

paginated_contents/algorithms/4th_thousand/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
| # | Title | Solutions | Video | Difficulty | Tag
22
|------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------|------------|----------------------------------------------------------------------
33
| 3502 | [Minimum Cost to Reach Every Position](https://leetcode.com/problems/minimum-cost-to-reach-every-position/) | [Java](https://github.com/fishercoder1534/Leetcode/blob/master/src/main/java/com/fishercoder/solutions/fourththousand/_3502.java) | | Easy |
4+
| 3491 | [Phone Number Prefix](https://leetcode.com/problems/phone-number-prefix/) | [Java](https://github.com/fishercoder1534/Leetcode/blob/master/src/main/java/com/fishercoder/solutions/fourththousand/_3491.java) | | Easy |
45
| 3471 | [Find the Largest Almost Missing Integer](https://leetcode.com/problems/find-the-largest-almost-missing-integer/) | [Java](https://github.com/fishercoder1534/Leetcode/blob/master/src/main/java/com/fishercoder/solutions/fourththousand/_3471.java) | | Easy |
56
| 3402 | [Minimum Operations to Make Columns Strictly Increasing](https://leetcode.com/problems/minimum-operations-to-make-columns-strictly-increasing/) | [Java](https://github.com/fishercoder1534/Leetcode/blob/master/src/main/java/com/fishercoder/solutions/fourththousand/_3402.java) | | Easy |
67
| 3396 | [Minimum Number of Operations to Make Elements in Array Distinct](https://leetcode.com/problems/minimum-number-of-operations-to-make-elements-in-array-distinct/) | [Java](https://github.com/fishercoder1534/Leetcode/blob/master/src/main/java/com/fishercoder/solutions/fourththousand/_3396.java) | | Easy |
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package com.fishercoder.solutions.fourththousand;
2+
3+
public class _3491 {
4+
public static class Solution1 {
5+
public boolean phonePrefix(String[] numbers) {
6+
for (int i = 0; i < numbers.length; i++) {
7+
for (int j = 0; j < numbers.length; j++) {
8+
if (i != j && numbers[i].startsWith(numbers[j])) {
9+
return false;
10+
}
11+
}
12+
}
13+
return true;
14+
}
15+
}
16+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package com.fishercoder.fourththousand;
2+
3+
import com.fishercoder.solutions.fourththousand._3491;
4+
import org.junit.jupiter.api.BeforeEach;
5+
import org.junit.jupiter.api.Test;
6+
7+
import static org.junit.jupiter.api.Assertions.assertEquals;
8+
9+
public class _3491Test {
10+
private _3491.Solution1 solution1;
11+
12+
@BeforeEach
13+
public void setup() {
14+
solution1 = new _3491.Solution1();
15+
}
16+
17+
@Test
18+
public void test1() {
19+
assertEquals(true, solution1.phonePrefix(new String[]{"1", "2", "4", "3"}));
20+
}
21+
}

0 commit comments

Comments
 (0)