id/email
password
forgot password | create account
about | help | code help+videos | done | prefs
CodingBat code practice

 

james.shockey@austinisd.org > calcDiagonal
prev  |  next  |  chance

/**
* calcDiagonal
* Returns an integer that is the sum of the main diagonal
* from (0,0) to (n,n)
*
*
* @param arr - a 1D integer array
* @param width - an integer with the width of the
* resulting 2D array rows
* @return the sum of the diagonal of the resulting 2D array.
*
*/


calcDiagonal([1, 2, 3, 4], 2) → 5
calcDiagonal([1, 2, 3, 4, 5, 6, 7, 8, 9], 3) → 15
calcDiagonal([1, 4, 76, 4, 85, 15, 9, 35, 77, 19, 100, 56, 81, 76, 27, 84], 4) → 200

...Save, Compile, Run (ctrl-enter)

int calcDiagonal(int[] arr, int width){ }

Editor font size %:
Shorter output


Forget It! -- delete my code for this problem

Progress graphs:
 Your progress graph for this problem
 Random user progress graph for this problem
 Random Epic Progress Graph

Java Help

Misc Code Practice

Copyright Nick Parlante 2017 - privacy