Compute the sum of the diagonal elements of an array (vector or matrix).
If array is not square return the char array: 'no-square'
If the input is empty, return [].
If the input is a scalar return the scalar number.
If any diagonal element is NaN, return NaN.
If any diagonal element is Inf, return Inf.
If both NaN and Inf appear among the diagonal, return -1.
Some built-in functions are forbidden.

Solution Stats

3 Solutions

3 Solvers

Last Solution submitted on May 01, 2026

Last 200 Solutions

Solution Comments

Show comments
Loading...