title: Find whether a 2d matrix is subset of another 2d matrix
body: <p>Recently i was taking part in one Hackathon and i came to know about a problem which tries to find a pattern of a grid form in a 2d matrix.A pattern could be U,H and T and will be represented by 3*3 matrix
  suppose if i want to present H and U</p>
  
  <pre><code>+--+--+--+            +--+--+--+
  |1 |0 |1 |            |1 |0 |1 |
  +--+--+--+            +--+--+--+
  |1 |1 |1 |  --&gt; H     |1 |0 |1 |    -&gt; U
  +--+--+--+            +--+--+--+
  |1 |0 |1 |            |1 |1 |1 |
  +--+--+--+            +--+--+--+
  </code></pre>
  
  <p>Now i need to search this into <code>10*10 matrix containing 0s and 1s</code>.Closest and only solution i can get it brute force algorithm of O(n^4).In languages like MATLAB and R there are very subtle ways to do this but not in C,C++. I tried a lot to search this solution on Google and on SO.But closest i can get is this <a href="https://stackoverflow.com/questions/1975386/fast-counting-of-2d-sub-matrices-withing-a-large-dense-2d-matrix">SO POST</a> which discuss about implementing <strong>Rabin-Karp string-search algorithm</strong> .But there is no pseudocode or any post explaining this.Could anyone help or provide any link,pdf or some logic to simplify this?</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>as Eugene Sh. commented that If N is the size of the large matrix(NxN) and k - the small one (kxk), the buteforce algorithm should take O((Nk)^2). Since k is fixed, it is reducing to O(N^2).Yes absolutely right.
  But is there is any generalised way if N and K is big?</p>