You are viewing a single comment's thread. Return to all comments →
one more condition for improving your algorithm if you already got all the alphabests in the hashSet , exit from for loop.
Ex:: for (int i = 0; i < s.length(); i++) { if(s.charAt(i)!=' '){ int put = (int)s.charAt(i); h.add(put); } //New code :: start if(h.size()==26) { break; } //New code :: end }
Seems like cookies are disabled on this browser, please enable them to open this website
Pangrams
You are viewing a single comment's thread. Return to all comments →
one more condition for improving your algorithm
if you already got all the alphabests in the hashSet , exit from for loop.
Ex::
for (int i = 0; i < s.length(); i++) {
if(s.charAt(i)!=' '){
int put = (int)s.charAt(i);
h.add(put);
}
//New code :: start
if(h.size()==26) {
break;
}
//New code :: end
}