You are viewing a single comment's thread. Return to all comments →
w = 'hackerrank'.chars s.chars.each {|c| w.shift if c == w[0] } puts w.empty? ? 'YES' : 'NO'
or the scary one-liner:
puts s.chars.reduce('hackerrank'.chars) {|acc,e| acc.shift if e == acc[0]; acc }.empty? ? 'YES' : 'NO'
Seems like cookies are disabled on this browser, please enable them to open this website
HackerRank in a String!
You are viewing a single comment's thread. Return to all comments →
or the scary one-liner: