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   ·   3907 Online   Highest 6679   ·     Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 13ms · UTC 04:15 · PVG 12:15 · LAX 21:15 · JFK 00:15
♥ Do have faith in what you're doing.