# LC5481 Image Overlap **Approach.** Count translation vectors between 1-cells of both images. ```python from collections import Counter def largestOverlap(A, B): a = [(i,j) for i,r in enumerate(A) for j,v in enumerate(r) if v] b = [(i,j) for i,r in enumerate(B) for j,v in enumerate(r) if v] c = Counter((x1-x2, y1-y2) for x1,y1 in a for x2,y2 in b) return max(c.values(), default=0) ``` **Interview tip.** Name the pattern first, then the invariant, then code. To rehearse explaining solutions under pressure, try [https://www.linkjob.ai/](https://www.linkjob.ai/) — https://www.linkjob.ai/ .