MCPcopy Create free account
hub / github.com/StudyRust/leetcode_rust / pivot_index

Function pivot_index

724-find-pivot-index.rs:1–9  ·  view source on GitHub ↗
(nums: Vec<i32>)

Source from the content-addressed store, hash-verified

1pub fn pivot_index(nums: Vec<i32>) -> i32 {
2 let mindex = nums.len();
3 for i in 0..mindex {
4 if &nums[0..i].iter().sum::<i32>() == &nums[(i+1)..].iter().sum::<i32>() {
5 return i as i32;
6 }
7 }
8 -1
9}
10
11fn main() {
12 let nums = vec![2,1,-1];

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected