title: How to check if matrix is tri-diagonal
body: <p>Assume we have the following matrix (below). I want to check if the matrix is tri-diagonal( All elements are zero except the main , upper and lower diagonal elements).</p>
  
  <pre><code>a[0][0] a[0][1] a[0][2]
  a[1][0] a[1][1] a[2][2]
  a[2][0] a[2][1] a[2][2]
  </code></pre>
  
  <p>I am not sure how to approach the problem. I have tried writing some code but nothing has been helpful. If someone could help me approach the problem, it would help. 
  I am writing this in java.</p>