subject

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;
}

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 23.06.2019 09:30
You wanted to look up information about alzheimer's, but you were unsure if it was spelled "alsheimer's" or "alzheimer's." which advanced search strategy would be useful? a) a boolean search b) using a wild card in your search c) trying different search engines d) doing a search for "alsheimer's not alzheimer's" asap. ill give brainlist.
Answers: 1
question
Computers and Technology, 23.06.2019 12:00
Using the list, you can select the number of photos that will appear on each slide. a. theme b. frame shape c. pictures in album d. picture layout
Answers: 1
question
Computers and Technology, 23.06.2019 15:30
Brian wants to conduct an online search with a certain phrase. he intends to use the words books that belong to the 1800s in his search. how should he use the word that in his search?
Answers: 1
question
Computers and Technology, 24.06.2019 05:30
Someone plzz me which of these defines a social search? a. asking a search engine a question that is answered by a real person on the other sideb. modifying search results based on popularity of a web pagec.modifying search results based on a ranking of a web page
Answers: 2
You know the right answer?
Consider a prison gate having N horizontal rods and M vertical rods. You are also provided with two...
Questions
question
Mathematics, 29.08.2019 08:10
question
Biology, 29.08.2019 08:10
question
Health, 29.08.2019 08:10
question
Mathematics, 29.08.2019 08:10
question
Mathematics, 29.08.2019 08:10
Questions on the website: 13722363