Ai
1 Star 2 Fork 5

LilithSangreal/LeetCode-Solutions

Create your Gitee Account
Explore and code with more than 13.5 million developers,Free private repositories !:)
Sign up
文件
Clone or Download
image-overlap.py 679 Bytes
Copy Edit Raw Blame History
Allen Liu authored 2018-10-12 01:33 +08:00 . remove sensitive question description
# Time: O(n^4)
# Space: O(n^2)
class Solution(object):
def largestOverlap(self, A, B):
"""
:type A: List[List[int]]
:type B: List[List[int]]
:rtype: int
"""
count = [0] * (2*len(A)-1)**2
for i, row in enumerate(A):
for j, v in enumerate(row):
if not v:
continue
for i2, row2 in enumerate(B):
for j2, v2 in enumerate(row2):
if not v2:
continue
count[(len(A)-1+i-i2)*(2*len(A)-1) +
len(A)-1+j-j2] += 1
return max(count)
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/LilithSangreal/LeetCode-Solutions.git
git@gitee.com:LilithSangreal/LeetCode-Solutions.git
LilithSangreal
LeetCode-Solutions
LeetCode-Solutions
master

Search