Lunski's Clutter

This is a place to put my clutters, no matter you like it or not, welcome here.

0%

371. Sum of Two Integers

Given two integers a and b, return the sum of the two integers without using the operators + and -.

Example 1:

1
2
Input: a = 1, b = 2
Output: 3

Example 2:

1
2
Input: a = 2, b = 3
Output: 5

不用+ 做加法,那用Sum看看,雖然有過,但題目中級,下次做應該要更深入,另外int是不能用sum加,要轉列表。

1
2
3
4
T:O(n), S:O(1)
class Solution(object):
def getSum(self, a, b):
return sum([a,b])

如果你覺得這篇文章很棒,請你不吝點讚 (゚∀゚)

Welcome to my other publishing channels