File tree Expand file tree Collapse file tree 4 files changed +13
-13
lines changed
solution/3400-3499/3450.Maximum Students on a Single Bench Expand file tree Collapse file tree 4 files changed +13
-13
lines changed Original file line number Diff line number Diff 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 }
Original file line number Diff line number Diff 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 }
Original file line number Diff line number Diff 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 }
Original file line number Diff line number Diff line change 11class 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+ }
You can’t perform that action at this time.
0 commit comments