My leetcode submissions.
1fn main() {
2 println!("Hello, world!");
3}
4
5impl Solution {
6 pub fn two_sum(numbers: Vec<i32>, target: i32) -> Vec<i32> {
7 for i in 0..numbers.len() {
8 if let Ok(comp) = numbers.binary_search(&(target - numbers[i])) {
9 match comp == i {
10 true => return vec![i as i32 + 1, comp as i32 + 2],
11 false => return vec![i as i32 + 1, comp as i32 + 1],
12 }
13 }
14 }
15 unreachable!();
16 }
17}