摘要:
这一题的关键是不能用O(N^3)的算法,肯定会LTE,O(N^2)的算法在于里面一层用贪心的方法向中间逼近逼近的速度可以用二分法优化,但是鉴于比较复杂这里就没写了C++代码: 1 class Solution { 2 public: 3 vector > threeSum(vector ... 阅读全文
摘要:
跟3sum题差不多,可以refer那题C++: 1 class Solution { 2 public: 3 int threeSumClosest(vector &num, int target) { 4 // Start typing your C/C++ solu... 阅读全文