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.
One way to improve it would to possibly put the return yes inside the for loop so you dont do any unneeded iterations because right now even if its already confirmed that it contains "hackerrank" in order it will continue through the rest of String s.
possibly do this inside the loop instead.
since it is the same amount of actions as combining the if statement and less if the j integer is already equal to the str length as well as adding a little more power to it.
but i love the
if(s.length()<str.length()){return"NO";}
I wish i would have thought of including that in my algorithm
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 →
One way to improve it would to possibly put the return yes inside the for loop so you dont do any unneeded iterations because right now even if its already confirmed that it contains "hackerrank" in order it will continue through the rest of String s. possibly do this inside the loop instead.
since it is the same amount of actions as combining the if statement and less if the j integer is already equal to the str length as well as adding a little more power to it.
but i love the
I wish i would have thought of including that in my algorithm