#229. 字符串递归计数:排除特定前缀
字符串递归计数:排除特定前缀
Count "hi" Occurrences
Background
Congcong is learning string processing and encounters an interesting recursive problem.
Problem Description
Given a string, compute recursively the number of times lowercase "hi" appears in the string. However, do not count "hi" that have an 'x' immediately before them.
Input Format
Input is given from Standard Input in the following format.
Output Format
Output is printed to Standard Output in the following format.
Count
Sample
ahixhi
1
ahibhi
2
xhixhi
0
Sample Explanation
For Sample 1 ahixhi: The first "hi" is preceded by 'x', so it's not counted; the second "hi" is preceded by 'h', so it's counted. Total 1.
For Sample 2 ahibhi: Both "hi" are not preceded by 'x', so both are counted. Total 2.
For Sample 3 xhixhi: The first "hi" is preceded by 'x', so it's not counted; the second "hi" is preceded by 'x', so it's not counted. Total 0.
Constraints
Time limit: 1 second, Memory limit: 1024 KiB for each test case.