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   ·   2391 Online   Highest 6679   ·     Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 16ms · UTC 02:01 · PVG 10:01 · LAX 19:01 · JFK 22:01
♥ Do have faith in what you're doing.