please can anybody explain me what this function do?i am confused
bool isOnlyLeftHand(string w) {
return (w.find_first_not_of("qwertasdfgzxcvb") == string::npos);
}//end isOnlyLeftHand
please can anybody explain me what this function do?i am confused
bool isOnlyLeftHand(string w) {
return (w.find_first_not_of("qwertasdfgzxcvb") == string::npos);
}//end isOnlyLeftHand
Returns true if the string can be entered with the left-hand only (on the keyboard) :)
This looks for characters that are not any of qwertasdfgzxcvb in the string w, and returns true if none are found (note the double negation).
In other words, return true if w can be typed using the left hand side of the keyboard.
It is literally checking for characters within the string that would be typed with the left handed.
The code find_first_not_of will scan the string and find the first position that is not part of the input w
returns true if any character other than those in the quoted string is absent in the input string represented by 'w'.