title: How to find that one matrix is submatrix of the other in C#?
body: <p>I want to find that a given matrix is a sub matrix of the other. </p>
  
  <p>I have tried below piece of code but I am not sure that it would work:-</p>
  
  <pre><code>for (int i = 0; i &lt; a.length - b.length + 1; i++) {
      for (int j = 0; j &lt; a[0].length - b[0].length + 1; j++) {
          boolean submatrix = true; // at start we assume we have a submatrix
          for (int k = 0; k &lt; b.length; ++k) {
              for (int l = 0; l &lt; b[0].length; ++l) {
                  if (a[i + k][j + l] == b[k][l]) {
                      Console.WriteLine("a[" + (i + k) + "][" + (j + l) + "] = b[" + k + "][" + l + "]");
                  } else {
                      submatrix = false; // we found inequality, so it's not a submatrix
                  }
              }
          }
          if (submatrix) {
              Console.WriteLine("Found subatrix at " + i + "," + j + ".");
          }
      }
  }
  </code></pre>
  
  <p>Please suggest??</p>