you give image img1 img2 represent binary square matrices size n x n a binary matrix 0s 1s valuesWe translate image choose slide 1 bit leave right andor number unit we place image we calculate overlap count number position 1 imagesnote translation include kind rotation any 1 bit translate outside matrix border erasedreturn large possible overlap Example 1input img1 110010010 img2 000011001output 3explanation we translate img1 right 1 unit 1 unitthe number position 1 image 3 show redexample 2input img1 1 img2 1output 1Example 3input img1 0 img2 0output 0 Constraintsn img1length img1ilengthn img2length img2ilength1 n 30img1ij 0 1img2ij 0 1