DEV Community

ZeeshanAli-0704
ZeeshanAli-0704

Posted on

HackerRank in a String!

function hackerrankInString(s) {
    // Write your code here

    let i=0;
    let j=0;
     let matchStr = "hackerrank";
    let isMatchFound = "NO";

    while(i < s.length){
        if(s[i] ===matchStr[j]){
            i++;
            j++;
        }else{
            i++;
        }

        if(j === matchStr.length){
            isMatchFound = "YES";
        } 
    }
 return isMatchFound;
}
Enter fullscreen mode Exit fullscreen mode

Top comments (0)