chutuocquyen
Senior Member
Python:
import numpy as np
class Solution:
def largestOverlap(self, img1: List[List[int]], img2: List[List[int]]) -> int:
n = len(img1[0])
a = np.pad(img1, ((0, 0), (0, n - 1))).ravel()
b = np.pad(img2, ((0, 0), (0, n - 1))).ravel()
tmp = int(2**(np.ceil(np.log2(2 * len(a) - 1))))
return round(np.fft.irfft(np.fft.rfft(a, tmp) * np.conj(np.fft.rfft(b, tmp)), n=tmp).max())
Sửa lần cuối:


