title: Occurance of a word in a matrix present in left to right, downwards or diagonal towards left(upward or downward)
body: <p>I have a input that defines the dimension of matrix, then 
  I have a square matrix of that dimension containing random alphabets given as input, I have a input string i want to search the string in the matrix, i can search this string in <strong>left to right horizontally</strong>, <strong>vertically downwards</strong> or <strong>diagonally towards left</strong>(both upwards and downwards)</p>
  
  <p>say for a given matrix </p>
  
  <pre><code>n = 3
  A A K
  A S K
  A K K
  
    00 01 02
  00 A  A  K 
  10 A  S  K
  20 A  K  K
  </code></pre>
  
  <p>and for a given string ASK i have to search all the occurrence of 'ASK'</p>
  
  <p>The output will be <strong><code>4</code></strong> as there are four occurance of 'ASK'</p>
  
  <p>2 are simple one : 01,11,21 and second : 10,11,12</p>
  
  <p>But i cant understand how to match the string diagonally upwards or downwards towards left.
  the 3rd : 02,11,20 and the 4th: 22,11,00</p>