标签:pre int leetcode span range rev sign ret type
#20181205
class Solution: def twoSum(self,nums, target): """ :type nums: List[int] :type target: int :rtype: List[int] """ n = len(nums) d = {} for i in range(n): a = target - nums[i] if nums[i] in d: return d[nums[i]], i else: d[a] = i
#20181206
class Solution: def reverse(self, x): """ :type x: int :rtype: int """ reverse_x = "" sign = "" if x < 0: x = -x sign = "-" for i in str(x): reverse_x = i + reverse_x reverse_x = sign + reverse_x if int(reverse_x) < pow(-2, 31) or int(reverse_x) > pow(2, 31) - 1: return 0 return int(reverse_x)
标签:pre int leetcode span range rev sign ret type
原文地址:https://www.cnblogs.com/ruanshuai/p/10080373.html