摘要: // 3SumClosest.cpp : 定义控制台应用程序的入口点。//#include "stdafx.h"#include #include#include #include using namespace std;class Solution {public: int threeSumClo... 阅读全文
posted @ 2014-10-16 21:11 supernigel 阅读(130) 评论(0) 推荐(0) 编辑
摘要: 类似3Sum,先排序,这后两重for循环,然后对最后的一个数组设两个指针遍历。这里注意重复的问题,例如第一重如果和前面一个数相同则跳过,因为前面的查找肯定包含了本次的情况。// 4Sum.cpp : 定义控制台应用程序的入口点。//#include "stdafx.h"#include #inclu... 阅读全文
posted @ 2014-10-16 16:24 supernigel 阅读(144) 评论(0) 推荐(0) 编辑
摘要: 思路: 1.将数组排序, 2.a 遍历 数组a[0]....a[n-1]; 3.当 a=a[i] 时 后面的问题 就是 : a[i+1] 到 a[n-1]中 b+c =-a (编程之美2.12 快速寻找满足条件的两个数 ) 记 b=a[j]=a[i... 阅读全文
posted @ 2014-10-16 14:22 supernigel 阅读(197) 评论(0) 推荐(0) 编辑