trivial coding in python (4 lines)


  • 1
    X
    class Solution(object):
        def getSum(self, a, b):
            """
            :type a: int
            :type b: int
            :rtype: int
            """
            s = []
            s.append(a)
            s.append(b)
            return sum(s)
    

  • 0
    T

    @xiaohan3
    Can be simplified even further to 1 line

    class Solution(object):
        def getSum(self, a, b):
            """
            :type a: int
            :type b: int
            :rtype: int
            """
            return sum([a, b])
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.