isLegal and containsPairSum11 completed