class Solution:
# @param {integer[]} nums
# @param {integer} target
# @return {integer[]}
def twoSum(self, nums, target):
intLen=len(nums)
if intLen <=1:
return False
res=[]
dicts={}
for i in range(0,intLen):
if not dicts.has_key(target-nums[i]):
dicts[nums[i]]=i
else:
tmpIndex=target-nums[i]
res.append(dicts[tmpIndex]+1)
res.append(i+1)
return res

leetcode two sum python的更多相关文章

  1. [leetcode]Path Sum @ Python

    原题地址:https://oj.leetcode.com/problems/path-sum/ 题意: Given a binary tree and a sum, determine if the ...

  2. leetcode Combination Sum python

    Given a set of candidate numbers (C) and a target number (T), find all unique combinations in C wher ...

  3. LeetCode:Path Sum I II

    LeetCode:Path Sum Given a binary tree and a sum, determine if the tree has a root-to-leaf path such ...

  4. 剑指offer 65. 不用加减乘除做加法(Leetcode 371. Sum of Two Integers)

    剑指offer 65. 不用加减乘除做加法(Leetcode 371. Sum of Two Integers) https://leetcode.com/problems/sum-of-two-in ...

  5. [LeetCode]题解(python):113 Path Sum II

    题目来源 https://leetcode.com/problems/path-sum-ii/ Given a binary tree and a sum, find all root-to-leaf ...

  6. [LeetCode]题解(python):112 Path Sum

    题目来源 https://leetcode.com/problems/path-sum/ Given a binary tree and a sum, determine if the tree ha ...

  7. [LeetCode]题解(python):064-Minimum Path Sum

    题目来源 https://leetcode.com/problems/minimum-path-sum/ Given a m x n grid filled with non-negative num ...

  8. [LeetCode]题解(python):124-Binary Tree Maximum Path Sum

    题目来源: https://leetcode.com/problems/binary-tree-maximum-path-sum/ 题意分析: 给定一棵树,找出一个数值最大的路径,起点可以是任意节点或 ...

  9. [LeetCode]题解(python):040-Combination Sum II

    题目来源 https://leetcode.com/problems/combination-sum-ii/ Given a collection of candidate numbers (C) a ...

随机推荐

  1. HDU Today(dijskra)

    HDU Today Time Limit: 15000/5000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total ...

  2. ASP.NET mvc4 WEB API异常处理

    当一个web api抛出一个异常后 此异常会被转化成一个HTTP响应 错误代码为500的服务错误 但是如果你不想让客户端看到500的错误码 你也可以自定义错误码 如下代码当用户输入的ID没有与之相关的 ...

  3. DevExpress控件之:ChartControl 动态绑定数据

    private void BindData(ViewType vt) { chartControl1.Series.Clear(); //Series series1 = new Series(&qu ...

  4. html系列教程--文本格式化

    <b>定义粗体文本</b> <br /> <strong>定义加重语气</strong> <br /> <big>定 ...

  5. SharePoint webpart中悬浮窗口的webconfig路径

    SharePoint webpart中悬浮窗口的webconfig路径在.../_layouts/15/下.

  6. Oracle 字符集问题

    1 简介 ORACLE数据库字符集,即Oracle全球化支持(Globalization Support),或即国家语言支持(NLS)其作用是用本国语言和格式来存储.处理和检索数据.利用全球化支持,O ...

  7. [转载]PDO防注入原理分析以及使用PDO的注意事项

    本文全部内容转载自月影无痕的博客http://zhangxugg-163-com.iteye.com/blog/1835721#bc2346092,感谢作者的分享 合理正确使用PDO,可以基本上防止S ...

  8. QF——网络之知识碎片

    1.URL中文问题: URL不支持中文.若出现中文,需要对URL进行utf-8编码. NSString *urlString = [kULRSTRING stringByAddingPercentEs ...

  9. php的cURL库介绍

    cURL 是一个利用URL语法规定来传输文件和数据的工具,支持很多协议,如HTTP.FTP.TELNET等.很多小偷程序都是使用这个函数.最爽的是,PHP也支持 cURL 库.本文将介绍 cURL 的 ...

  10. 通过 IP 访问谷歌

    最近貌似谷歌都不能访问,对于我等经常使用谷歌的人说不是件好事,毕竟谷歌比百度专业,好在有解决办法: 1. 找到文件:C:\Windows\System32\drivers\etc\hosts 2. 把 ...