
C++版:
class Solution {
public:
vector twoSum(vector& nums, int target) {
int i,j;
vector s;
for(i=0;i
python版:
class Solution(object):
def twoSum(self, nums, target):
"""
:type nums: List[int]
:type target: int
:rtype: List[int]
"""
n = len(nums)
for x in range(n):
for y in range(x+1,n):
if(nums[x]+nums[y]==target):
return x,y
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)