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.
use "j" as a start point to pass to the indexOf() method.
iterate through the length of "hR" to see if the given string has a character matching that of the current "hR" character using the indexOf() method with a starting search index which is 1 greater than the last character matched, hence adding 1 to the return value of indexOf() and saving it in "j"..
indexOf() will return -1 if it ever fails to match any of the characters, thus if j == 0 after checking for a match, we return "NO"
HackerRank in a String!
You are viewing a single comment's thread. Return to all comments →
Absolutely...