码迷,mamicode.com
首页 > 其他好文 > 详细

[LeetCode] Image Overlap 图像重叠

时间:2019-02-07 23:23:10      阅读:214      评论:0      收藏:0      [点我收藏+]

标签:href   div   tran   ted   put   value   problems   example   this   

 

Two images A and B are given, represented as binary, square matrices of the same size.  (A binary matrix has only 0s and 1s as values.)

We translate one image however we choose (sliding it left, right, up, or down any number of units), and place it on top of the other image.  After, the overlap of this translation is the number of positions that have a 1 in both images.

(Note also that a translation does not include any kind of rotation.)

What is the largest possible overlap?

Example 1:

Input: A = [[1,1,0],
            [0,1,0],
            [0,1,0]]
       B = [[0,0,0],
            [0,1,1],
            [0,0,1]]
Output: 3
Explanation: We slide A to right by 1 unit and down by 1 unit.

Notes: 

  1. 1 <= A.length = A[0].length = B.length = B[0].length <= 30
  2. 0 <= A[i][j], B[i][j] <= 1
 

s

 

参考资料:

https://leetcode.com/problems/image-overlap/

 

[LeetCode] Image Overlap 图像重叠

标签:href   div   tran   ted   put   value   problems   example   this   

原文地址:https://www.cnblogs.com/grandyang/p/10355589.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!