2016年3月1日

4Sum

摘要: 注意当有四个时,其实第一个和第二个性质等于三个数和时的第一个。 class Solution { public: vector<vector<int>> fourSum(vector<int>& nums, int target) { vector<vector<int>> res; int i,j 阅读全文

posted @ 2016-03-01 22:26 RenewDo 阅读(157) 评论(0) 推荐(0) 编辑

Letter Combinations of a Phone Number

摘要: 遍历所有的可能。 1 class Solution { 2 private: 3 vector<string> res; 4 map<char,string> num; 5 public: 6 void initial() 7 { 8 9 num['2']="abc"; 10 num['3']="d 阅读全文

posted @ 2016-03-01 19:51 RenewDo 阅读(183) 评论(0) 推荐(0) 编辑

3Sum Closest

摘要: 大致思路还和3Sum一样:先排序,然后固定第一个数,后面的范围用两个指针确定,当大于目标值时,右指针左移,当小于目标值时,左指针右移。 需要注意的:第一每次改变三个数其中一个都要再次计算总和,判断。 1 class Solution { 2 public: 3 int threeSumClosest 阅读全文

posted @ 2016-03-01 16:33 RenewDo 阅读(115) 评论(0) 推荐(0) 编辑

导航