We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
I got the same logic. You can improve this a little bit.
Rather than declaring 'j' outside the for loop, declare it inside.
Return "YES" when the j == str.length() within the for loop itself. So that that it won't have to loop through other characters once you know that "hackerrank" is already present.
Return "NO" outside the for loop.
Cookie support is required to access HackerRank
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 →
I got the same logic. You can improve this a little bit.
Rather than declaring 'j' outside the for loop, declare it inside.
Return "YES" when the j == str.length() within the for loop itself. So that that it won't have to loop through other characters once you know that "hackerrank" is already present.
Return "NO" outside the for loop.