[LeetCode] Two Sum
摘要:问题:找出数组中两个数之和等于一个给定目标数。并输出这两个数在数组中的下标。1.暴力O(n^2),两个for循环查找,TLE。 1 class Solution { 2 public: 3 vector twoSum(vector &numbers, int target) { 4 5 vector ans; 6 for (int i = 0; i &a, const pair &b) { 2 if (a.first == b.first) return a.second twoSum(vector &numbers, int...
阅读全文
posted @ 2014-02-01 21:33