this function owns the nums and ret
(mut nums: Vec<i32>, target: i32)
| 7 | impl Solution { |
| 8 | /// this function owns the nums and ret |
| 9 | pub fn four_sum(mut nums: Vec<i32>, target: i32) -> Vec<Vec<i32>> { |
| 10 | if nums.len() < 4 { return vec![] } |
| 11 | nums.sort(); |
| 12 | println!("nums = {:?}", nums); |
| 13 | let mut ret = vec![]; |
| 14 | for i in 0..nums.len() - 3 { |
| 15 | if i > 0 && nums[i - 1] == nums[i] { continue } |
| 16 | Self::three_sum(nums[i], &nums[i + 1..nums.len()], target, &mut ret); |
| 17 | } |
| 18 | ret |
| 19 | } |
| 20 | |
| 21 | /// implement the default O(n^2) three sum |
| 22 | /// nums must be at least 3 element long |
nothing calls this directly
no outgoing calls
no test coverage detected