Im looking to receive a jagged array of type int[][] and then run through the arrays to find the specific array with the highest sum and then return that sum. Ive done some digging online and haven't found much info about how to sum up each array individually.
For example if this was the received input:
int[][] accounts = new int[3][];
accounts[0] = new int[] { 1, 2, 3};
accounts[1] = new int[] { 2, 3, 4 };
accounts[2] = new int[] { 3, 4, 5 };
The closest I've come to this was getting the total sum of all elements
for (var i = 0; i < accounts.Length; i++)
{
for (var j = 0; j < accounts[i].Length; j++)
{
sum += accounts[i][j];
}
}
What step am I missing to separate the arrays and sum them up individually?