Tony's Log

Algorithms, Distributed System, Machine Learning

  博客园 :: 首页 :: 新随笔 :: 联系 :: 订阅 :: 管理 ::

2014年8月18日

摘要: Similar strategy could be applied to 4Sum, as 2sum to 3sum, but that'll be O(n^3). Instead of 3 + 1, we can also divide it into 2 + 2. So the problem ... 阅读全文
posted @ 2014-08-18 12:23 Tonix 阅读(188) 评论(0) 推荐(0)

摘要: Simply a variation of 3Sum:class Solution {public: int threeSumClosest(vector &num, int target) { int ret = 99999999999; std::sort(nu... 阅读全文
posted @ 2014-08-18 10:39 Tonix 阅读(140) 评论(0) 推荐(0)

摘要: Now that you've solved 2sum, 3sum can be easily converted as 2sum.Also please note the while loops for i1 and i2: they are to make sure no duplicates.... 阅读全文
posted @ 2014-08-18 10:12 Tonix 阅读(152) 评论(0) 推荐(0)