Sam and substrings Discussions | Algorithms | HackerRank
  • Asked to answer
    + 1 comment

    You can download and inspect the test cases to debug your code, watching its behaviour on inputs resulting in fails. If the first case works you might have a problem counting all occurrences of the search word in areas where it appears twice or at the beginning or end of the line (e.g. foo food (foo) bar foob foo foo should yield 4), but debugging with known test inputs is generally a good direction here.