about | help | code help+videos | done | prefs |
Write a method with the following pre-conditions: str will contain a string that may be empty. toCount will contain a single character which may or may not appear in str. unless will contain a single character which may or may not appear in str. The method returns the number of times the character in toCount appears in str, except that the character in toCount is NOT counted if it comes immediately after the character in unless. For example: countLettersUnless("all fly last",'l','f') will return 3 because the letter 'l' appears 4 times, but one of those times it comes right after an 'f', so that one is not counted. countLettersUnless("once upon a time there was a computer", "z", "u") → 0 countLettersUnless("once upon a time there was a computer", "e", "r") → 4 countLettersUnless("lfkasjdjhadsouweorifuadslfikjgd", "r", "i") → 1 ...Save, Compile, Run (ctrl-enter) |
Progress graphs:
Your progress graph for this problem
Random user progress graph for this problem
Random Epic Progress Graph
Difficulty: 290
Copyright Nick Parlante 2017 - privacy