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.
This will sometimes be more efficient than a solution that applies one check to each character in the string until it finds a match, then moves onto the next check. But sometimes it will be much more inefficient. This is because you apply all the checks to all the characters in the string, every time, even if checks have already been passed. So, if a string is 1000 characters long and all 5 checks are passec in the first few characters, you still go on to apply 5000 checks to 1000 characters. In contrast, a solution that uses the any function to check the string for each check in sequence will apply no more than 15 checks to 5 characters.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
String Validators
You are viewing a single comment's thread. Return to all comments →
This will sometimes be more efficient than a solution that applies one check to each character in the string until it finds a match, then moves onto the next check. But sometimes it will be much more inefficient. This is because you apply all the checks to all the characters in the string, every time, even if checks have already been passed. So, if a string is 1000 characters long and all 5 checks are passec in the first few characters, you still go on to apply 5000 checks to 1000 characters. In contrast, a solution that uses the any function to check the string for each check in sequence will apply no more than 15 checks to 5 characters.