MCPcopy Create free account
hub / github.com/Blankj/awesome-java-leetcode / fourSum

Method fourSum

src/com/blankj/medium/_0018/Solution.java:57–64  ·  view source on GitHub ↗
(int[] nums, int target)

Source from the content-addressed store, hash-verified

55// }
56
57 public List<List<Integer>> fourSum(int[] nums, int target) {
58 Arrays.sort(nums);
59 int len = nums.length;
60 if (len < 4) return Collections.emptyList();
61 int max = nums[len - 1];
62 if (4 * max < target) return Collections.emptyList();
63 return kSum(nums, 0, 4, target);
64 }
65
66 private List<List<Integer>> kSum(int[] nums, int start, int k, int target) {
67 List<List<Integer>> res = new ArrayList<>();

Callers 1

mainMethod · 0.95

Calls 1

kSumMethod · 0.95

Tested by

no test coverage detected