Weikoi

导航

2020年3月6日 #

Leetcode-016-最接近的三数之和

摘要: 先排序,然后双指针。 class Solution { public int threeSumClosest(int[] nums, int target) { int res = nums[0]+nums[1]+nums[2]; Arrays.sort(nums); for(int i=0;i<n 阅读全文

posted @ 2020-03-06 14:30 Weikoi 阅读(118) 评论(0) 推荐(0) 编辑

Leetcode-015-三数之和

摘要: 先排序,再用双指针,注意的是解中是没有重复的情况的,所以需要跳过。 class Solution { public List<List<Integer>> threeSum(int[] nums) { List<List<Integer>> res = new ArrayList<>(); Arra 阅读全文

posted @ 2020-03-06 00:32 Weikoi 阅读(109) 评论(0) 推荐(0) 编辑