python刷题

1.两数之和

class Solution:
    def twoSum(self, nums: List[int], target: int) -> List[int]:
        for i in range(0,len(nums)):
            if target>=0:
                if nums[i]<=target:
                    a = i
                    sub = nums[i]
                    nums[i] = target+32768
                    try:
                        b = nums.index(target-sub)
                        if a==b:
                            continue
                        else:
                            return [a,b]
                    except:
                        continue
                else:
                    continue
            else:
                if nums[i]>=target:
                    a = i
                    sub = nums[i]
                    nums[i] = target+10
                    try:
                        b = nums.index(target-sub)
                        if a==b:
                            continue
                        else:
                            return [a,b]
                    except:
                        continue
                else:
                    continue
上一篇:BUUCTF Reverse/[GUET-CTF2019]number_game


下一篇:ABAC权限控制学习