#P7313. Maximum HONI Subsequences
Maximum HONI Subsequences
Maximum HONI Subsequences
Given a word of length \(N\), remove any number of letters such that you can form as many subsequences of the string \(HONI\) as possible. A valid subsequence is formed by deleting zero or more characters without changing the order of the remaining characters.
Note: The letters in each \(HONI\) must appear in order. For example, in the word HHONIHONI
, you can form 2 subsequences \(HONI\).
inputFormat
The first line contains an integer \(N\) (the length of the word). The second line contains a string of \(N\) uppercase letters.
outputFormat
Output a single integer: the maximum number of subsequences \(HONI\) that can be formed.
sample
4
HONI
1