Skip to content

Commit 86de9eb

Browse files
committed
fix: solutions
1 parent 4ece8da commit 86de9eb

File tree

4 files changed

+13
-13
lines changed

4 files changed

+13
-13
lines changed

solution/3400-3499/3450.Maximum Students on a Single Bench/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ public:
156156
}
157157
int ans = 0;
158158
for (const auto& s : d) {
159-
ans = max(ans, (int)s.second.size());
159+
ans = max(ans, (int) s.second.size());
160160
}
161161
return ans;
162162
}

solution/3400-3499/3450.Maximum Students on a Single Bench/README_EN.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ public:
154154
}
155155
int ans = 0;
156156
for (const auto& s : d) {
157-
ans = max(ans, (int)s.second.size());
157+
ans = max(ans, (int) s.second.size());
158158
}
159159
return ans;
160160
}

solution/3400-3499/3450.Maximum Students on a Single Bench/Solution.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@ class Solution {
33
int maxStudentsOnBench(vector<vector<int>>& students) {
44
unordered_map<int, unordered_set<int>> d;
55
for (const auto& e : students) {
6-
d[e[0]].insert(e[1]);
6+
int studentId = e[0], benchId = e[1];
7+
d[benchId].insert(studentId);
78
}
89
int ans = 0;
9-
for (auto& [_, s] : d) {
10-
ans = max(ans, (int) s.size());
10+
for (const auto& s : d) {
11+
ans = max(ans, (int) s.second.size());
1112
}
1213
return ans;
1314
}
Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
class Solution {
2-
public:
3-
int maxStudentsOnBench(vector<vector<int>>& students) {
4-
unordered_map<int, unordered_set<int>> d;
5-
for (const auto& e : students) {
2+
public int maxStudentsOnBench(int[][] students) {
3+
Map<Integer, Set<Integer>> d = new HashMap<>();
4+
for (var e : students) {
65
int studentId = e[0], benchId = e[1];
7-
d[benchId].insert(studentId);
6+
d.computeIfAbsent(benchId, k -> new HashSet<>()).add(studentId);
87
}
98
int ans = 0;
10-
for (const auto& s : d) {
11-
ans = max(ans, (int)s.second.size());
9+
for (var s : d.values()) {
10+
ans = Math.max(ans, s.size());
1211
}
1312
return ans;
1413
}
15-
};
14+
}

0 commit comments

Comments
 (0)