You are viewing a single comment's thread. Return to all comments →
function diagonalDifference(array Extra open brace or missing close bracearraySize = count($arr);
// primary & secondary sum vars `$primarySum = $`secondarySum = 0; // looping the array for (`$x = 0; $`x < `$arraySize; $`x++) { // incrementing primary sum `$primarySum += $`arr[`$x][$`x]; // incrementing secondary sum `$secondarySum += $`arr[`$x][$`arraySize - 1 - $x]; } // return absolute diagonal return abs(`$primarySum - $`secondarySum);
};
Seems like cookies are disabled on this browser, please enable them to open this website
Diagonal Difference
You are viewing a single comment's thread. Return to all comments →
Solution in PHP
function diagonalDifference(array arraySize = count($arr);
};