title: Matrix Comparison algorithm
body: <p>If you have 2 Matrices of dimensions N*M.
  what is the best way to get the difference Rect?</p>
  
  <p>Example:</p>
  
  <pre><code>2 3 2 3 2 3 2 3                      2 3 2 3 2 3 2 3
  2 3 2 3 2 3 2 3                      2 3 2 3 2 3 2 3
  2 3 4 5 4 3 2 3      &lt;---&gt;           2 3 2 3 2 3 2 3
  2 3 4 5 2 3 2 3                      2 3 2 3 2 3 2 3
  2 3 2 3 2 3 2 3                      2 3 2 3 2 3 2 3
  
                        |
                        |
                       \ /
               Rect([2,2] , [3,4])
                      4 5 4
                      4 5 2-&gt; A (2 x 3 Matrix)
  </code></pre>
  
  <p>The best I could think of is to scan from Top-Left hit the point where there is difference.
  Then scan from Bottom Right and hit the point where there is a difference.</p>
  
  <p>But In worst case, this is O(N*M). is there a better efficient algorithm? Or is there something I could do with how I represent them, so that you can apply a more efficient algorithm? And mind you, this Matrix can be very big.</p>