Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit3636dab

Browse files
[LEET-3450] add 3450
1 parentdd67dd3 commit3636dab

File tree

3 files changed

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

3 files changed

+47
-0
lines changed

‎paginated_contents/algorithms/4th_thousand/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
| 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|
55
| 3477|[Fruits Into Baskets II](https://leetcode.com/problems/fruits-into-baskets-ii/)|[Java](https://github.com/fishercoder1534/Leetcode/blob/master/src/main/java/com/fishercoder/solutions/fourththousand/_3477.java)|| Easy|
66
| 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|
7+
| 3450|[Maximum Students on a Single Bench](https://leetcode.com/problems/maximum-students-on-a-single-bench/)|[Java](https://github.com/fishercoder1534/Leetcode/blob/master/src/main/java/com/fishercoder/solutions/fourththousand/_3450.java)|| Easy|
78
| 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|
89
| 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|
910
| 3392|[Count Subarrays of Length Three With a Condition](https://leetcode.com/problems/count-subarrays-of-length-three-with-a-condition/)|[Java](https://github.com/fishercoder1534/Leetcode/blob/master/src/main/java/com/fishercoder/solutions/fourththousand/_3392.java)|| Easy|
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
packagecom.fishercoder.solutions.fourththousand;
2+
3+
importjava.util.HashMap;
4+
importjava.util.HashSet;
5+
importjava.util.Map;
6+
importjava.util.Set;
7+
8+
publicclass_3450 {
9+
publicstaticclassSolution1 {
10+
publicintmaxStudentsOnBench(int[][]students) {
11+
Map<Integer,Set<Integer>>map =newHashMap<>();
12+
for (int[]student :students) {
13+
Set<Integer>set =map.getOrDefault(student[1],newHashSet<>());
14+
set.add(student[0]);
15+
map.put(student[1],set);
16+
}
17+
intresult =0;
18+
for (Map.Entry<Integer,Set<Integer>>entry :map.entrySet()) {
19+
result =Math.max(result,entry.getValue().size());
20+
}
21+
returnresult;
22+
}
23+
}
24+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
packagecom.fishercoder.fourththousand;
2+
3+
importcom.fishercoder.common.utils.CommonUtils;
4+
importcom.fishercoder.solutions.fourththousand._3450;
5+
importorg.junit.jupiter.api.BeforeEach;
6+
importorg.junit.jupiter.api.Test;
7+
8+
importstaticorg.junit.jupiter.api.Assertions.assertEquals;
9+
10+
publicclass_3450Test {
11+
private_3450.Solution1solution1;
12+
13+
@BeforeEach
14+
publicvoidsetup() {
15+
solution1 =new_3450.Solution1();
16+
}
17+
18+
@Test
19+
publicvoidtest1() {
20+
assertEquals(3,solution1.maxStudentsOnBench(CommonUtils.convertLeetCodeIrregularLengths2DArrayInputIntoJavaArray("[1,2],[2,2],[3,3],[1,3],[2,3]")));
21+
}
22+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp