What would be the best logic to check all the letters in a given string.
If all the 26 letters are available in the provided string, I want to check that and perform
You could iterate over your string for each letter of the alphabet you want to check. When you find the letter you are looking for, continue with the next. If you don’t, abort. Here is some pseudo-code:
found = true;
for (letter in letters) {
if (!string.contains(letter)) {
found = false;
break;
}
}
This way you do not need to store the information for each letter but you have to search the string again and again for each letter. What you end up using will depend on your requirements: should it be fast? Should it use little memory? Your decision. :)