Beautiful Pairs

  • + 0 comments

    Ruby

    def beautifulPairs(a, b)
        summation = (a & b).map {|e| [a.count(e), b.count(e)].min }.sum
        (summation < b.length) ? summation + 1 : summation-1    
    end