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 sum = lv + rv;
if sum < k {
if lv < rv {
left += 1;
} else {
right -= 1;
}
} else if sum > k {
if rv > lv {
right -= 1;
} else {
left += 1;
}
} else {
max += 1;
left += 1;