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

 

jebbert@volusia.k12.fl.us > test2022_12_08_SLHL_sumExcludedList
prev  |  next  |  chance

Write a method that returns the sum of all the numbers in array 'nums' but not including any numbers that match any values of the array 'excluded'. Both arrays can be any length, including length zero. Each number could be positive, negative, or zero. All numbers are included in the sum except those that also appears somewhere in the 'excluded' array. For example, if 'nums' is {5,7,3,1,10,2,7} and 'excluded' is {7,5,10}, the sum would be 3+1+10+2 which is 16. Look at the test data for more examples.


test2022_12_08_SLHL_sumExcludedList([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1]) → 0
test2022_12_08_SLHL_sumExcludedList([1, 2, 3, 4, 5, -10, 40, 50, 100, -2, 3], [100]) → 96
test2022_12_08_SLHL_sumExcludedList([50, 60, 20, 40, 20], [20]) → 150

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

public int test2022_12_08_SLHL_sumExcludedList(int[] nums, int[] excluded) { }

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