You are viewing a single comment's thread. Return to all comments →
since j starts from 0 and with "hackerrank" check, j value will be 9, so return (j == str.length() ? "YES" : "NO");
might not work for same cases. It might be like this
return (j+1 == str.length() ? "YES" : "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 →
since j starts from 0 and with "hackerrank" check, j value will be 9, so return (j == str.length() ? "YES" : "NO");
might not work for same cases. It might be like this
return (j+1 == str.length() ? "YES" : "NO");