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

 

sumSome


Write a method that returns the sum of all the numbers in an integer array. Except do not count any numbers that come immediately after a value of zero. For example, sumSome({0, 5, 0, 7, 2, 1}) returns a value of 3. Note that the 5 and the 7 are not added into the sum because they came immediately after a value of zero.


sumSome([7, 0, 3, 0, 11, 0, 18, 0, 6]) → 7
sumSome([0, 2, 0, 0, 5, 0, 8, 0]) → 0
sumSome([5, 7, 0, 3, -8, 1]) → 5

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

public int sumSome(int[] nums) { }

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: 250

Copyright Nick Parlante 2017 - privacy