Diagonal Difference

  • + 1 comment

    You are absolutely right. That being said, sometimes it may be better to write code that exhibits explicitly its logic, here "summing the elements of the diagonal of a square matrix" and for this purpose using a 2-D array could be better here I guess.

    But yes, when it comes to performances, storing data used only once is clearly ineffective.