about | help | code help+videos | done | prefs |
Write a method that returns the number of times 'target' appears in 'str', but with no overlaps allowed. For example, "aaa" appears THREE times in "aaaaaaaaa". Once you use the first three characters as a match, you cannot use any of those again or you would have overlap. Look at the test data for further examples. test2021_04_29_P1SLHL_countMatches("amanaplanacanalpanama", "an") → 4 test2021_04_29_P1SLHL_countMatches("rrrrrrrrrrrrrrrrrrrrrrrrrr", "rr") → 13 test2021_04_29_P1SLHL_countMatches("no overlap is allowed", "not here") → 0 ...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: 250
Copyright Nick Parlante 2017 - privacy