leetcode 1 rust
题目
代码
pub fn two_sum(nums: Vec<i32>, target: i32) -> Vec<i32> {
let len = nums.len();
let mut a:Vec<i32> = vec![0;len];
for i in 0..len {
for j in 0 .. i {
if a[j] == nums[i] {
let result = vec![j as i32,i as i32];
return result;
}
}
a[i] = target - nums[i];
}
[0,0].to_vec()
}
posted on 2021-04-08 13:41 GeniusOfCX 阅读(46) 评论(0) 编辑 收藏 举报