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 閱讀(53) 評(píng)論(0) 收藏 舉報(bào)
浙公網(wǎng)安備 33010602011771號(hào)