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 so ops. eg. Pack my box with five dozen liquor jugs.
BTW my code would be in Java.
Using a BitMap, I'm assuming you meant case insenstive.
Update: Solution by Thomas is more efficient, than the following. :) Use that one.
//
String test = "abcdefeghjiklmnopqrstuvwxyz";
BitSet alpha = new BitSet(26);
for(char ch : test.toUpperCase().toCharArray())
if(Character.isLetter(ch))
alpha.set(ch - 65);
System.out.println(alpha.cardinality() == 26);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With