
该题可暴力求解,直接看代码:
#include<bits/stdc++.h>
using namespace std;
int main(){
int n;
vector<int> x1, y1, x2, y2;
cin>>n;
int res=1;
int input;
for(int i=0; i<n; i++){
cin>>input;
x1.push_back(input);
}
for(int i=0; i<n; i++){
cin>>input;
y1.push_back(input);
}
for(int i=0; i<n; i++){
cin>>input;
x2.push_back(input);
}
for(int i=0; i<n; i++){
cin>>input;
y2.push_back(input);
}
for(int x:x1){
for(int y:y1){
int cnt=0;
for(int i=0; i<n; i++){
if(x>=x1[i] && x<x2[i] && y>=y1[i] && y<y2[i]){
cnt++;
}
}
res = max(

这篇博客探讨了LeetCode中关于矩形重叠问题的解决方案。通过暴力求解的方法,文章详细阐述了如何利用代码找出横线和竖线在其他矩形之间的关键点,从而解决这一问题。
最低0.47元/天 解锁文章
658

被折叠的 条评论
为什么被折叠?



