From edbe0571dc60edd4fcaa4b78f38bc39ec728d7a4 Mon Sep 17 00:00:00 2001 From: Joe Ardent Date: Tue, 14 May 2024 16:38:44 -0700 Subject: [PATCH] tidy --- find_pivot_index/src/main.rs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/find_pivot_index/src/main.rs b/find_pivot_index/src/main.rs index 5463c27..e024fb2 100644 --- a/find_pivot_index/src/main.rs +++ b/find_pivot_index/src/main.rs @@ -3,7 +3,6 @@ fn main() { } fn f(nums: Vec) -> i32 { - let mut pivot = -1; let mut rights = Vec::with_capacity(nums.len()); let mut cur = 0; for n in nums.iter().rev() { @@ -16,9 +15,8 @@ fn f(nums: Vec) -> i32 { for (i, num) in nums.into_iter().enumerate() { cur += num; if cur == rights[i] { - pivot = i as i32; - break; + return i as i32; } } - pivot + -1 }