i got this problem from: http://codingbat.com/prob/p178318
This is the question:
Given a string, return the count of the number of times that a substring length 2 appears in the string and also as the last 2 chars of the string, so "hixxxhi" yields 1 (we won't count the end substring).
last2("hixxhi") → 1
last2("xaxxaxaxx") → 1
last2("axxxaaxx") → 2
I can easily find the solution, but I'd like to understand the question first.
This is my interpretation:
- the x's are not counted, they are not included in substring (i'm guessing)
- i don't get why the result for the 2nd example and 3rd example.
- i don't get whay they mean by " we wont count the end substring"
any help is much appreciated, thanks.