#-*- coding: UTF-8 -*-
#AC源码【意外惊喜,还以为会超时】
class Solution(object):
def twoSum(self, nums, target):
"""
:type nums: List[int]
:type target: int
:rtype: List[int]
"""
for i in xrange(len(nums)):
tmp=target-nums[i]
curList=nums[i+1:]
if curList.__contains__(tmp):
return [i,i+curList.index(tmp)+1]
else:continue
return []
sol=Solution()
print sol.twoSum([-1,-2,-3,-4,-5],-8)
相关文章
- 03-20【leetcode❤python】Sum Of Two Number
- 03-20【leetcode❤python】 1. Two Sum
- 03-20LeetCode-001 Two Sum
- 03-20LeetCode之Easy篇 ——(1)Two Sum
- 03-201. Two Sum——LeetCode
- 03-20【LeetCode 1. Two Sum】
- 03-20Leetcode 1.两数之和 By Python
- 03-20Leetcode167-Two Sum II Input array is sorted-Easy
- 03-20[LeetCode&Python] Problem 371. Sum of Two Integers
- 03-20[LeetCode]题解(python):004-Median of Two Sorted Arrays