about | help | code help+videos | done | prefs |
Write a method that returns the number of times the 'target' string appears in the 'source' string. Overlaps are NOT allowed. For example, given 'source'="aaaaaa" and 'target'="aaa" your method must return 2 since there are two non-overlapping "aaa" strings within "aaaaaa". The only string methods you are allowed to use are .length, .substring, .equals, .compareTo, or .charAt. If you use a for-loop you must make sure you follow the conventions established in class... otherwise use a different kind of loop. Neither of the parameters will be an empty string. Note that the 'target' string could be longer than the 'source' string or vis-versa. nov4_SLHL_countMatches("slip", "way to long") → 0 nov4_SLHL_countMatches("Hi", "i") → 1 nov4_SLHL_countMatches("aaaaaa", "aa") → 3 ...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: 280
Copyright Nick Parlante 2017 - privacy