• 大小: 52KB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2021-05-13
  • 语言: Python
  • 标签: Python  

资源简介

python习题

资源截图

代码片段和文件信息

“““
Given an array of integers return indices of the two numbers
such that they add up to a specific target.
You may assume that each input would have exactly one solution
and you may not use the same element twice.

Example:
    Given nums = [2 7 11 15] target = 9
    Because nums[0] + nums[1] = 2 + 7 = 9
    return [0 1].
“““

# 和为目标值即目标值与其中一数的差在数组中
class Solution:
    def twoSum(self nums target):
        “““
        :type nums: List[int]
        :type target: int
        :rtype: List[int]
        “““
        dict_temp = {}
        for i value in enumerate(nums):
            if value in dict_temp:
                return(dict_temp[value] i)
            else:
                dict_temp[target - value] = i

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2019-01-17 17:33  leetcode_python-master\
     目录           0  2019-01-17 17:33  leetcode_python-master\001-100\
     文件         768  2019-01-17 17:33  leetcode_python-master\001-100\001_twoSum.py
     文件         810  2019-01-17 17:33  leetcode_python-master\001-100\007_reverseInteger.py
     文件        2757  2019-01-17 17:33  leetcode_python-master\001-100\008_stringtiInteger.py
     文件         806  2019-01-17 17:33  leetcode_python-master\001-100\009_palindromeNumber.py
     文件        2288  2019-01-17 17:33  leetcode_python-master\001-100\013_romantoInteger.py
     文件         866  2019-01-17 17:33  leetcode_python-master\001-100\014_longestCommonPrefix.py
     文件         872  2019-01-17 17:33  leetcode_python-master\001-100\019_removeNthNodeFromEndofLiist.py
     文件         848  2019-01-17 17:33  leetcode_python-master\001-100\020_validParentheses.py
     文件        1625  2019-01-17 17:33  leetcode_python-master\001-100\026_removeDuplicatesfromSortedArray.py
     文件        1738  2019-01-17 17:33  leetcode_python-master\001-100\027_removeElement.py
     文件         855  2019-01-17 17:33  leetcode_python-master\001-100\028_implementstrStr.py
     文件         827  2019-01-17 17:33  leetcode_python-master\001-100\035_searchInsertPosition.py
     文件         946  2019-01-17 17:33  leetcode_python-master\001-100\038_countandSay.py
     文件         781  2019-01-17 17:33  leetcode_python-master\001-100\043_multiplyStrings.py
     文件         587  2019-01-17 17:33  leetcode_python-master\001-100\046_permytations.py
     文件        1100  2019-01-17 17:33  leetcode_python-master\001-100\048_rotateImage.py
     文件         732  2019-01-17 17:33  leetcode_python-master\001-100\058_lengthofLastWord.py
     文件         896  2019-01-17 17:33  leetcode_python-master\001-100\066_plusOne.py
     文件         475  2019-01-17 17:33  leetcode_python-master\001-100\067_addBinary.py
     文件         723  2019-01-17 17:33  leetcode_python-master\001-100\070_climbingStairs.py
     文件         778  2019-01-17 17:33  leetcode_python-master\001-100\088_mergeSortedArray.py
     目录           0  2019-01-17 17:33  leetcode_python-master\101-200\
     文件         650  2019-01-17 17:33  leetcode_python-master\101-200\118_pascalsTriangle.py
     文件        1407  2019-01-17 17:33  leetcode_python-master\101-200\122_bestTimetoBuyandSellStockII.py
     文件         581  2019-01-17 17:33  leetcode_python-master\101-200\125_validPalindrome.py
     文件         552  2019-01-17 17:33  leetcode_python-master\101-200\136_singleNumber.py
     文件        1260  2019-01-17 17:33  leetcode_python-master\101-200\141_linkedListCycle.py
     文件         860  2019-01-17 17:33  leetcode_python-master\101-200\169_majorityElement.py
     文件         631  2019-01-17 17:33  leetcode_python-master\101-200\171_excelSheetColumnNumber.py
............此处省略59个文件信息

评论

共有 条评论