Computers and Technology, 17.06.2021 16:10 princessmaddiegigi
Consider a prison gate having N horizontal rods and M vertical rods.
You are also provided with two vectors hor and ver containing the
row number of missing horizontal rods and vertical rods respectively.
Return the area of biggest hole in the prison gate.
1 <= N, M <= 1000000
1 <= hor[i] <= N
1 <= ver[i] <= M
All the elements of a vector are distinct
O(N + M)
SKIPPING... O(AlogA + BlogB) where A = hor. size() and B = ver. size()
*/
#include
using namespace std;
long int prison(int n, int m, vector hor, vector ver) {
vector xs(n + 1), ys(m + 1);
for (int h : hor) xs[h] = true;
for (int v : ver) ys[v] = true;
int xm = 0, ym = 0;
for (int i = 1, j = 0; i <= n; i++) { if (not xs[i]) j = 0;
else xm = max(xm, ++j);
}
for (int i = 1, j = 0; i <= m; i++) {
if (not ys[i]) j = 0;
else ym = max(ym, ++j);
}
return (long int)(xm + 1) * (ym + 1);
}
int main() {
cout << prison(10, 10, {}, {});
return 0;
}
Answers: 1
Computers and Technology, 23.06.2019 08:00
The managing director of a company sends a christmas greeting to all his employees through the company email. which type of network does he use? he uses an .
Answers: 3
Computers and Technology, 23.06.2019 14:00
What is html ? give a small description about html
Answers: 2
Computers and Technology, 23.06.2019 15:30
The processing of data in a computer involves the interplay between its various hardware components.
Answers: 1
Computers and Technology, 24.06.2019 22:10
How many different ways are there to order the eight jobs in the queue so that job usu comes somewhere before cdp in the queue (although not necessarily immediately before) and cdp comes somewhere before bbd (again, not necessarily immediately before)?
Answers: 1
Consider a prison gate having N horizontal rods and M vertical rods.
You are also provided with two...
Social Studies, 18.05.2021 18:50
Geography, 18.05.2021 18:50
Mathematics, 18.05.2021 18:50
Mathematics, 18.05.2021 18:50
Social Studies, 18.05.2021 18:50
Geography, 18.05.2021 18:50
English, 18.05.2021 18:50
Computers and Technology, 18.05.2021 18:50
English, 18.05.2021 18:50