From e8b350b64b0e0a2f1b4a9f30b8f258ed638d9413 Mon Sep 17 00:00:00 2001 From: Joe Ardent Date: Fri, 26 Apr 2024 10:19:31 -0700 Subject: [PATCH] remove pointless ifs --- max_k_sum_pairs/src/main.rs | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/max_k_sum_pairs/src/main.rs b/max_k_sum_pairs/src/main.rs index c1db6c4..4979934 100644 --- a/max_k_sum_pairs/src/main.rs +++ b/max_k_sum_pairs/src/main.rs @@ -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; - } + left += 1; } else if sum > k { - if rv > lv { - right -= 1; - } else { - left += 1; - } + right -= 1; } else { max += 1; left += 1;