Leetcode oj1 第一题 two sum
来源:互联网 发布:索恩马克体测数据 编辑:程序博客网 时间:2024/06/01 10:50
Given an array of integers, return indices of the two numbers such that they add up to a specific target.
You may assume that each input would have exactly one solution, and you may not use the same element twice.
Example:
Given nums = [2, 7, 11, 15], target = 9,Because nums[0] + nums[1] = 2 + 7 = 9,较简单,直接上代码:return [0, 1].
class Solution: def twoSum(self, nums, target): """ :type nums: List[int] :type target: int :rtype: List[int] """ for s,i in enumerate(nums[:len(nums)-1]): for s1,j in enumerate(nums[s+1:]): if i+j==target: k=[s,s1+s+1] return k
阅读全文
0 0
- Leetcode oj1 第一题 two sum
- leetcode OJ1 Two Sum求解小结
- leetcode 第一题 two sum
- LeetCode 第一题,Two Sum
- leetcode第一题two sum
- Two Sum leetcode第一题
- two Sum leetCode第一题
- leetcode 第一题:two sum
- LeetCode第一题Two Sum
- Leetcode第一题--------- Two Sum
- Leetcode第一题<two sum>
- LeetCode第一题:Two Sum
- leetcode------第一题 Two Sum
- LeetCode 1.Two Sum ------------LeetCode 第一题
- Leetcode 第一题 Two Sum java代码
- Leetcode 之第一题 two sum
- 第一题: Two Sum
- 第一题 two-sum
- 写给自己的JAVA工程师之路-数据链路层
- Binary Search:475. Heaters
- 表单验证
- unity常见面试题
- ubuntu16.04安裝Django
- Leetcode oj1 第一题 two sum
- 基于java的enigma的加密程序
- 构建高性能的ASP.NET应用(10)
- java.util.concurrent中的Condition与wait/notify区别
- UnityDrawCall优化
- 美团技术团队:实例详解机器学习如何解决问题(转载)
- Next Permutation--LeetCode
- TabLayout,ViewPager,Fragment,实现联动
- zuul动态配置路由规则,从DB读取