blob: 43527dbeb0383e3660d8b4cad686d4eb75def99b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
#include "leetcode.h"
class Solution {
public:
int largestOverlap(vvd(int) & img1, vvd(int) & img2) {
vector<int> la, lb;
int n = img1.size();
unordered_map<int, int> count;
for (int i = 0; i < n * n; ++i)
if (img1[i / n][i % n] == 1)
la.push_back(i / n * 100 + i % n);
for (int i = 0; i < n * n; ++i)
if (img2[i / n][i % n] == 1)
lb.push_back(i / n * 100 + i % n);
for (int i : la)
for (int j : lb)
count[i - j]++;
int ans = 0;
for (auto it : count)
ans = max(ans, it.second);
return ans;
}
};
|