0

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.

1
Contributor
1
Reply
12
Views
4 Years
Discussion Span
Last Post by mferarri
0

i got it now. it should be, count the repetitons of the last 2 chars of the string.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.