Skip to content

Commit 02237ad

Browse files
add 2441
1 parent fbcb5b8 commit 02237ad

File tree

3 files changed

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

3 files changed

+42
-0
lines changed

paginated_contents/algorithms/3rd_thousand/README.md

+1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
| 2485 | [Find the Pivot Integer](https://leetcode.com/problems/find-the-pivot-integer/) | [Java](https://github.com/fishercoder1534/Leetcode/blob/master/src/main/java/com/fishercoder/solutions/thirdthousand/_2485.java) || Easy ||
3535
| 2467 | [Convert the Temperature](https://leetcode.com/problems/convert-the-temperature/) | [Java](https://github.com/fishercoder1534/Leetcode/blob/master/src/main/java/com/fishercoder/solutions/thirdthousand/_2469.java) || Easy ||
3636
| 2455 | [Average Value of Even Numbers That Are Divisible by Three](https://leetcode.com/problems/average-value-of-even-numbers-that-are-divisible-by-three/) | [Java](https://github.com/fishercoder1534/Leetcode/blob/master/src/main/java/com/fishercoder/solutions/thirdthousand/_2455.java) || Easy ||
37+
| 2441 | [Largest Positive Integer That Exists With Its Negative](https://leetcode.com/problems/largest-positive-integer-that-exists-with-its-negative/) | [Java](https://github.com/fishercoder1534/Leetcode/blob/master/src/main/java/com/fishercoder/solutions/thirdthousand/_2441.java) || Easy ||
3738
| 2433 | [Find The Original Array of Prefix Xor](https://leetcode.com/problems/find-the-original-array-of-prefix-xor/) | [Java](https://github.com/fishercoder1534/Leetcode/blob/master/src/main/java/com/fishercoder/solutions/thirdthousand/_2433.java) | [:tv:](https://youtu.be/idcT-p_DDrI) | Medium ||
3839
| 2432 | [The Employee That Worked on the Longest Task](https://leetcode.com/problems/the-employee-that-worked-on-the-longest-task/) | [Java](https://github.com/fishercoder1534/Leetcode/blob/master/src/main/java/com/fishercoder/solutions/thirdthousand/_2432.java) || Easy ||
3940
| 2427 | [Number of Common Factors](https://leetcode.com/problems/number-of-common-factors/) | [Java](https://github.com/fishercoder1534/Leetcode/blob/master/src/main/java/com/fishercoder/solutions/thirdthousand/_2427.java) || Easy ||
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package com.fishercoder.solutions.thirdthousand;
2+
3+
import java.util.HashSet;
4+
import java.util.Set;
5+
6+
public class _2441 {
7+
public static class Solution1 {
8+
public int findMaxK(int[] nums) {
9+
int maxK = -1;
10+
Set<Integer> set = new HashSet<>();
11+
for (int i = 0; i < nums.length; i++) {
12+
set.add(nums[i]);
13+
if (set.contains(-nums[i])) {
14+
maxK = Math.max(maxK, Math.abs(nums[i]));
15+
}
16+
}
17+
return maxK;
18+
}
19+
}
20+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package com.fishercoder.thirdthousand;
2+
3+
import com.fishercoder.solutions.thirdthousand._2441;
4+
import org.junit.jupiter.api.BeforeEach;
5+
import org.junit.jupiter.api.Test;
6+
7+
import static org.junit.Assert.assertEquals;
8+
9+
public class _2441Test {
10+
private static _2441.Solution1 solution1;
11+
12+
@BeforeEach
13+
public void setup() {
14+
solution1 = new _2441.Solution1();
15+
}
16+
17+
@Test
18+
public void test1() {
19+
assertEquals(7, solution1.findMaxK(new int[]{-1, 10, 6, 7, -7, 1}));
20+
}
21+
}

0 commit comments

Comments
 (0)