Find words that can be typed using only one row on a keyboard
Algorithm/Data Structure Selection

Right now you're using three separate sets, one of the letters in each row of the keyboard.

Instead, I think I'd use a single map from character to row number. Then you can start with the first character in the string, and find what row it's on. Then you check whether the other characters in the word are in the same row. Right now, you may look up each character in a string up to three separate times. Changing the algorithm, you can reduce that to (at most) one lookup per character.

Since you have a dense set of inputs for the map (i.e., only ASCII letters) I'd probably also use an array/vector for the mapping, instead of an unordered map. A vector/array will avoid hashing, and it's a dense structure, so you get really good cache utilization.

Avoid Unnecessary Transformations

It's probably simpler to create a mapping for all possible input characters instead of using toupper on the input, then looking it up in the set/map.

Consider other Looping Constructs

Instead of a loop like this:

            size_t wordSize = words.size();
            for(size_t j = 0; j &lt; wordSize; ++j)
            {
                if(row.find(toupper(words[j])) == row.end())
                {
                   return false;
                }
            }


I'd probably use a loop more like this:

for (auto c : words[j] )
    if (row.find(c) == row.end())
        return false;
return true;


...or you could use a standard algorithm instead:

return std::all_of(words[j].begin(), words[j].end(), 
    [&amp;](char c) { return row.find(c) != row.end(); });


(Though, as outlined above, I'd rather change it to look up the row number instead).