title: How to detect adjacent entries in an array?
body: <p>"Write a method in Java that returns true if there are k adjacent occurrences of a symbol in the same row, column, or diagonal of a checkered board (two-dimensional array), where k is the number of symbols inline desired."</p>
  
  <p>How can I do this? I have a rough idea of how to check rows and columns (very rough; no code, just thoughts) but I'm at a loss for checking the diagonal.</p>
  
  <p>Edit: one other situation I'm thinking about: how can I check arbitrary positions? Right now, I'm only considering occurrences starting at (0,0), but what if there's a string of 3 from, say, (2,3) to (2,6)? How could I keep track of multiple occurrences?</p>
  
  <p>EDIT: Detecting the left diagonal (rough code for a question I posted in the comments below):</p>
  
  <pre><code>LeftDiagonal(x, symbol) {
      noOfOccurence = 0;
  
      for (currentX = (size - 1); currentX &gt;= x; currentX--) {
          if (board[currentX][currentX] == symbol) {
              noOfOccurence++;
          } else {
              break;
          }
      }
  
      return (noOfOccurence &gt;= k);
  }
  </code></pre>