문제
https://leetcode.com/problems/two-sum/
풀이
impl Solution {
pub fn two_sum(nums: Vec<i32>, target: i32) -> Vec<i32> {
let mut answer = Vec::new();
for i in 0..nums.len() {
for j in (i+1)..nums.len() {
if nums[i] + nums[j] == target {
answer.push(i as i32);
answer.push(j as i32);
break;
}
}
}
answer
}
}
댓글