remove pointless ifs

This commit is contained in:
Joe Ardent 2024-04-26 10:19:31 -07:00
parent ae5d866555
commit e8b350b64b

View file

@ -17,17 +17,9 @@ fn foo(nums: &mut [i32], k: i32) -> i32 {
let rv = nums[right]; let rv = nums[right];
let sum = lv + rv; let sum = lv + rv;
if sum < k { if sum < k {
if lv < rv { left += 1;
left += 1;
} else {
right -= 1;
}
} else if sum > k { } else if sum > k {
if rv > lv { right -= 1;
right -= 1;
} else {
left += 1;
}
} else { } else {
max += 1; max += 1;
left += 1; left += 1;