@ -35,13 +35,16 @@ impl SolutionHashMap {
}
// Driver Code
fn main() {
// ======= Test Case =======
let nums = vec![2,7,11,15];
let target = 9;
// 方法一
let res = SolutionBruteForce::two_sum(&nums, target);
println!("方法一 res = {:?}", res);
// 方法二
let res = SolutionHashMap::two_sum(&nums, target);
println!("方法二 res = {:?}", res);
@ -15,6 +15,7 @@ fn constant(n: i32) -> i32 {
count
/* 线性阶 */
fn linear(n: i32) -> i32 {
let mut count = 0;
for _ in 0..n {