You are viewing a single comment's thread. Return to all comments →
Java:
public static String hackerrankInString(String s) { String pattern = "hackerrank"; int patternLength = pattern.length(); int patternPointer = 0; for(int i = 0; i < s.length(); i++) { if(s.charAt(i) == pattern.charAt(patternPointer)) { patternPointer++; if(patternPointer == patternLength) { return "YES"; } } } return "NO"; }
Seems like cookies are disabled on this browser, please enable them to open this website
An unexpected error occurred. Please try reloading the page. If problem persists, please contact support@hackerrank.com
HackerRank in a String!
You are viewing a single comment's thread. Return to all comments →
Java: