文件名称:leetcode添加元素使和等于-DailyAlgorithm:leetcode刷题笔记
文件大小:122KB
文件格式:ZIP
更新时间:2024-07-20 00:32:33
系统开源
leetcode添加元素使和等于 leetcode进阶之路,道阻且长 1.数组之和 ### 解题之前需要先想好各种可能情况,比如[],[1],[3,3],[1,2,3,4,3]等特殊情况 示例: 给定 nums = [2, 7, 11, 15], target = 9 因为 nums[0] + nums[1] = 2 + 7 = 9 所以返回 [0, 1] ''' #获取list中的值和索引的对应关系 cc = [1, 2, 3, 2, 4] from collections import defaultdict dd = defaultdict(list) for k, va in [(v,i) for i, v in enumerate(cc)]: dd[k].append(va) print(dd) ''' def twoSum(self, nums, target): res = [] for index,i in enumerate(nums):#enumerate同时获取索引和值 temp = [] b = target - i if b in nums[index+1:]
【文件预览】:
DailyAlgorithm-master
----Tree_5()
--------tree_traversals.py(4KB)
--------README.md(14KB)
----DFSAndRecursive_20()
--------README.md(8KB)
----leetcode()
--------longestCommonPrefix.py(601B)
--------threeSum.py(3KB)
--------ZigzagTransformation.py(1010B)
--------nextPermutation.py(1KB)
--------isPalindrome.py(381B)
--------letterCombinations.py(3KB)
--------removeNthFromEnd.py(666B)
--------removeElement.py(1KB)
--------romanToInt.py(1KB)
--------strToInt.py(251B)
--------generateParenthesis.py(2KB)
--------strStr.py(495B)
--------isMatch.py(1KB)
--------swapPairs.py(1KB)
--------mergeTwoLists.py(1KB)
--------threeSumClosest.py(3KB)
--------FindMedia.py(2KB)
--------maxArea.py(1KB)
--------__init__.py(101B)
--------twoSum.py(730B)
--------fourSum.py(1KB)
--------longestValidParentheses.py(1KB)
--------findSubstring.py(1KB)
--------FindTheLongestReturnString.py(4KB)
--------divide.py(2KB)
--------ReversInteger.py(672B)
--------twoNumAdd.py(2KB)
--------reverseKGroup.py(2KB)
--------isValid.py(870B)
--------intToRoman.py(940B)
--------mergeKLists.py(996B)
--------longestSubstringWithoutRepeatingCharacters.py(1KB)
----BinarySearchAndDivide_15()
--------README.md(16KB)
----TwoPoint_10()
--------README.md(2KB)
----DynamicProgramming_30()
--------arraySonSum.py(1KB)
--------0-1Bag.py(1KB)
--------coinChange.py(596B)
--------HouseRobberII_213.py(1KB)
--------HouseRobber198.py(749B)
--------README.md(35KB)
----Sort()
--------sort_top10.py(6KB)
--------README.md(7KB)
----README.md(39KB)
----Link_20()
--------README.md(15KB)
----HashTable_8()
--------README.md(3KB)
----swardToOffer()
--------twoCharTress.py(3KB)
--------longestCommonPrefix.py(1KB)
--------LeftRotateString.py(742B)
--------isNumeric.py(2KB)
--------Add.py(737B)
--------deleteDuplication.py(2KB)
--------twoCharSearchTreeAndBiLink.py(2KB)
--------IsBalanced_Solution.py(1KB)
--------printListFromTailToHead.py(741B)
--------PrintMinNumber.py(1KB)
--------permutations.py(1KB)
--------Print_twoChatTreeMultiRows.py(1KB)
--------Print_zhizi.py(2KB)
--------EntryNodeOfLoop.py(2KB)
--------KthNode.py(1KB)
--------GetUglyNumber_Solution.py(2KB)
--------medianOfDataStream.py(593B)
--------FirstNotRepeatingChar.py(1KB)
--------Sum_Solution.py(542B)
--------FindFirstCommonNode.py(3KB)
--------StrToInt.py(1KB)
--------IsContinuous.py(2KB)
--------NumberOf1Between1AndN_Solution.py(494B)
--------ReverseSentence.py(718B)
--------duplicate.py(957B)
--------FindContinuousSequence.py(909B)
--------serializeAndDeserialize.py(1KB)
--------FirstAppearingOnce.py(596B)
--------fromOneToNHaveOne.py(1KB)
--------FindNumsAppearOnce.py(676B)
--------isSymmetrical.py(1KB)
--------GetNext.py(3KB)
--------TreeDepth.py(1KB)
--------match.py(2KB)
--------GetNumberOfK.py(2KB)
--------LinkNode.py(4KB)
--------copyComplexLink.py(1KB)
--------charArray.py(380B)
--------Find.py(909B)
--------LastRemaining_Solution.py(682B)
--------FindNumbersWithSum.py(767B)
--------multiply.py(574B)
--------replaceSpace.py(661B)
--------InversePairs.py(4KB)
----BFSAndTopologicalSort_8()
--------README.md(5KB)