huanyouchen's recent timeline updates
huanyouchen

huanyouchen

V2EX member #323022, joined on 2018-06-15 22:33:43 +08:00
huanyouchen's recent replies
Jun 30, 2018
Replied to a topic by a476286557 Python leetcode 两数之和 Python 求解答
通过字典构建一个哈希表:
class Solution:
def twoSum(self, nums, target):
dic = {}
for i,num in enumerate(nums):
if num in dic:
return [dic[num],i]
else:
dic[target-num] = i
About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   5338 Online   Highest 6679   ·     Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 13ms · UTC 08:37 · PVG 16:37 · LAX 01:37 · JFK 04:37
♥ Do have faith in what you're doing.