#!/bin/ruby q = gets.strip.to_i for a0 in (0..q-1) s = gets.strip # your code goes here result = "NO" hr = "hackerrank".split('') cc = 0 s.split('').each do |c| if c == hr[cc] cc += 1 end if cc == hr.length result = "YES" break end end puts result end