#C7161. Forming 'Hello' Rearrangement
Forming 'Hello' Rearrangement
Forming 'Hello' Rearrangement
Given a string s consisting of lowercase English letters, determine if it is possible to rearrange the characters of s so that it contains the word \(\text{hello}\) as a subsequence with the exact frequency of characters, i.e. one 'h', one 'e', two 'l's, and one 'o'.
Formally, let \(f(c)\) denote the frequency of character \(c\) in s. The answer is "YES" if and only if:
\[ f(h) \ge 1,\quad f(e) \ge 1,\quad f(l) \ge 2,\quad f(o) \ge 1. \]Otherwise, the answer is "NO".
inputFormat
The input is given via standard input (stdin) and consists of a single line containing a non-empty string s made up of lowercase English letters.
outputFormat
Output a single line to standard output (stdout) containing either YES
if the string can be rearranged to form the word hello
, or NO
otherwise.
lloeh
YES