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

 

sum3Elem


Given an array of ints with odd length, return the sum of the first, middle, and the last element of the array. If the length of the array is less than 3, return the sum of all elements inside the array.


sum3Elem([1, 2, 3]) → 6
sum3Elem([1]) → 1
sum3Elem([1, 0, 4, -2, 3]) → 8

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

public int sum3Elem(int[] arr) { }

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

Difficulty: 120

Copyright Nick Parlante 2017 - privacy