#213. 递归统计子串出现次数

    ID: 213 Type: Default 1000ms 256MiB Tried: 0 Accepted: 0 Difficulty: (None) Uploaded By: Tags>codingbatWarmup-2gesp5递归字符串

递归统计子串出现次数

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.

s The input consists of a single line containing a string ss.

Output Format

Output is printed to standard output in the following format.

count Output 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.