You are viewing a single comment's thread. Return to all comments →
Using a Queue in C# does the job.
Just check each letter in a queue. If the queue is emptied out, then we have "hackerrank" in the text.
private static string HasHackerRankInText(string text) { var hackerrank = new Queue<char>("hackerrank".ToCharArray()); foreach (char c in text) { if (c == hackerrank.Peek()) hackerrank.Dequeue(); if (hackerrank.Count == 0) return "YES"; } return "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 →
Using a Queue in C# does the job.
Just check each letter in a queue. If the queue is emptied out, then we have "hackerrank" in the text.