public class Solution { /* * @param numbers: An array of Integer * @param target: target = numbers[index1] + numbers[index2] * @return: [index1 + 1, i... ...
分类:
其他好文 时间:
2017-10-12 01:04:06
阅读次数:
113
最简单的就是写两个循环,但写两个循环的时间复杂度o(n^2)太差了,一般不会是个很好的算法。 别人的代码: ...
分类:
其他好文 时间:
2017-10-12 01:03:58
阅读次数:
105
1. Two Sum 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 wo ...
分类:
其他好文 时间:
2017-10-05 21:26:25
阅读次数:
134
题目链接:https://leetcode.com/problems/two-sum/description/ LeetCode第一号题目,难度是easy,通过率却只有35%。 看完题目描述感觉确实简单: 给你一个整数数组nums,以及一个整数target,要求从nums中找到两个和为target的 ...
分类:
其他好文 时间:
2017-10-04 12:36:52
阅读次数:
131
167. Two Sum II - Input array is sorted【easy】 Given an array of integers that is already sorted in ascending order, find two numbers such that they ad ...
分类:
其他好文 时间:
2017-10-03 15:56:20
阅读次数:
196
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 ex ...
分类:
其他好文 时间:
2017-09-28 16:48:50
阅读次数:
154
Given a Binary Search Tree and a target number, return true if there exist two elements in the BST such that their sum is equal to the given target. E ...
分类:
其他好文 时间:
2017-09-26 21:00:45
阅读次数:
203
Given an array of integers that is already sorted in ascending order, find two numbers such that they add up to a specific target number. The function ...
分类:
编程语言 时间:
2017-09-24 20:29:38
阅读次数:
202
class Solution { public: //int compare(const void * arg1, const void *arg2) //{ //return (*(int*)arg1 - *(int*)arg2); //} vector twoSum(vector& nums, ... ...
分类:
其他好文 时间:
2017-09-24 00:27:34
阅读次数:
109
这道题为简单题 题目: 思路: 这道题可以利用字典,遍历列表,如果目标值target - numbers[i]存在于字典中,那么就返回当前元素的索引和target - numbers[i]的索引,否则就将该元素加入到字典中,键值为该元素的索引 代码: ...
分类:
其他好文 时间:
2017-09-21 23:23:37
阅读次数:
162