const 课程地址 = " http://icourse8.com/gocjxt.html ";
章节信息
第1章 课程介绍【预备,初识】
第2章 6种抽奖活动来一遍【伸展运动,舒缓热身】
第3章 系统设计和架构设计【扩胸运动,有容乃大】
第4章 项目框架与核心代码【踢腿运动,固若磐石】
第5章 后台功能开发【体侧运动,运筹帷幄】
第6章 基于mysql的抽奖功能开发【体转运动,基础版本】
第7章 使用redis缓存优化【全身运动,升级版本】
第8章 奖品池以及发奖计划的实现【跳跃运动,极致版本】
第9章 完整性演示以及更多总结【整理运动,整体交付】
第10章 引入thrift框架【附加运动,扩展服务】
第11章 课程总结【结束,沉淀】
class Solution { public List<List<Integer>> threeSum(int[] nums) { Arrays.sort(nums); List<List<Integer>> ls = new ArrayList<>(); for (int i = 0; i < nums.length - 2; i++) { if (i == 0 || (i > 0 && nums[i] != nums[i - 1])) { // 跳过可能重复的答案 int l = i + 1, r = nums.length - 1, sum = 0 - nums[i]; while (l < r) { if (nums[l] + nums[r] == sum) { ls.add(Arrays.asList(nums[i], nums[l], nums[r])); while (l < r && nums[l] == nums[l + 1]) l++; while (l < r && nums[r] == nums[r - 1]) r--; l++; r--; } else if (nums[l] + nums[r] < sum) { while (l < r && nums[l] == nums[l + 1]) l++; // 跳过重复值 l++; } else { while (l < r && nums[r] == nums[r - 1]) r--; r--; } } } } return ls; } }