I have checked and couldn’t a better option by checking the word’s letters one by one. I’ve decided to use the ascii equivalence of the letter check by diving the word but didn’t lead to any where as well. Any Ideas?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Clearly in the worst case it can’t be done without examining every character. Whichever character(s) you don’t examine, might be the same as the others or different, and the result needs to be sensitive to that in the case where the ones you do examine are all the same.
If you know something about what might be in the string, then the order in which you examine the characters might affect how early you can bail out. But knowing nothing, you may as well read them in order, and reading them in order might result in better cache performance.
Things get more complicated if the string is long enough that it’s worth parallelizing.