#213. 递归统计子串出现次数
递归统计子串出现次数
Count 'hi' Recursively
Background
Congcong is currently learning about string manipulation. He encountered an interesting problem that requires counting the occurrences of a specific substring within a given string, but only using a recursive approach.
Problem Description
Given a string, compute recursively (no loops) the number of times lowercase "hi" appears in the string.
Input Format
Input is given from standard input in the following format.
sThe input consists of a single line containing a string .
Output Format
Output is printed to standard output in the following format.
countOutput a single integer representing the number of times 'hi' appears in the string.
Sample
xxhixx
1
xhixhix
2
hi
1
Sample Explanation
For the first sample xxhixx, 'hi' appears once in the string.
For the second sample xhixhix, 'hi' appears twice in the string.
For the third sample hi, 'hi' appears once in the string.
Constraints
Time limit: 1 second per test case. Memory limit: 1024 KiB per test case.