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

 

countOccurrences


Given two Strings, str1 and str2, return the number of times str2 is contained within str1.


countOccurrences("1 1 2 2 3 3 2 2 1 1", "1") → 4
countOccurrences("one two three four", "o") → 3
countOccurrences("one two three four", "three") → 1

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

public int countOccurrences(String str1, String str2){ }

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: 200 Post-solution available

Copyright Nick Parlante 2017 - privacy