Skip to content

Commit 514862b

Browse files
committed
15 init
1 parent 90746a0 commit 514862b

File tree

2 files changed

+48
-0
lines changed

2 files changed

+48
-0
lines changed

src/array/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@ mod best_time_to_buy_and_sell_stock;
22
mod container_with_most_water;
33
mod contains_duplicate;
44
mod product_of_array_except_self;
5+
mod three_sum;
56
mod two_sum;

src/array/three_sum.rs

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#![allow(dead_code)]
2+
3+
/*
4+
#15 3Sum
5+
6+
Given an integer array nums, return all the triplets
7+
[nums[i], nums[j], nums[k]] such that
8+
i != j, i != k, and j != k, and nums[i] + nums[j] + nums[k] == 0.
9+
10+
Notice that the solution set must not contain duplicate triplets.
11+
12+
Constraints:
13+
3 <= nums.length <= 3000
14+
-10^5 <= nums[i] <= 10^5
15+
*/
16+
17+
/*
18+
T:
19+
S:
20+
*/
21+
pub fn solution_a<N>(_nums: N) -> Vec<Vec<i32>> {
22+
vec![]
23+
}
24+
25+
#[cfg(test)]
26+
mod tests {
27+
use super::*;
28+
29+
#[test]
30+
fn a_0() {
31+
assert_eq!(
32+
solution_a(vec![-1, 0, 1, 2, -1, -4]),
33+
vec![vec![-1, -1, 2], vec![-1, 0, 1]]
34+
);
35+
}
36+
37+
#[test]
38+
fn a_1() {
39+
let right: Vec<Vec<i32>> = vec![];
40+
assert_eq!(solution_a(vec![0, 1, 1]), right);
41+
}
42+
43+
#[test]
44+
fn a_2() {
45+
assert_eq!(solution_a(vec![0, 0, 0]), vec![vec![0, 0, 0]]);
46+
}
47+
}

0 commit comments

Comments
 (0)