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

 

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

A dataset was found to contain "bad" data. Write a method that finds out how many times 'bad' appears in the array 'nums', except it is OK to have 'bad' in the first or last position in the array, so those don't count towards the total number of 'bad' values. (NOTE: HL students MUST solve this recursively) Look at the test data for examples. Note that the array can be any length, including zero.


todays_2021_11_01_APSLHL_countBad([7], 7) → 0
todays_2021_11_01_APSLHL_countBad([], 2) → 0
todays_2021_11_01_APSLHL_countBad([34, 32, 66, 234, 13, 5434, 4, 5, 4, 554, 335, 1, 5324, 46, 544, 352, 23, 55, 4, 45, 6, 4, 78, 6, 32, 53, 3, 4, 4, 5, 7, 4], 4) → 6

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

public int todays_2021_11_01_APSLHL_countBad(int[] nums, int bad) { }

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

Copyright Nick Parlante 2017 - privacy