Yes, OP does need to watch indentation and braces, but I don't think he is missing anything important here.
a.size() cannot be less than zero.
However, if a.size() equals zero, then OP has a problem. Test for that.
By convention, the maximum value of an empty set is zero. (Not NaN.)
For the second problem, neither solution is correct. The point of merging two ordered sets is:
- given two choices (first item in a and first item in b)
- take the smallest[1] and append it to the result.
Repeat until both a and b are exhausted.
1 (It need not be the smallest, per se, it need be the item that comes first in the final set.)