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.
Of course this will work, but you should note that using substring is very inefficient. It creates a copy of the string before comparing. Better to use charAt(index) and break out of the loop as soon as a comparison fails.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
The Grid Search
You are viewing a single comment's thread. Return to all comments →
Of course this will work, but you should note that using substring is very inefficient. It creates a copy of the string before comparing. Better to use charAt(index) and break out of the loop as soon as a comparison fails.