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

Function is_arithmetic

413-arithmetic-slices.rs:3–9  ·  view source on GitHub ↗
(nums: &[i32])

Source from the content-addressed store, hash-verified

1pub fn number_of_arithmetic_slices(nums: Vec<i32>) -> i32 {
2 if nums.len() < 3 { return 0; }
3 pub fn is_arithmetic(nums: &[i32]) -> bool {
4 let minus = nums[1] - nums[0];
5 for i in 2..nums.len() {
6 if nums[i] - nums[i-1] != minus { return false; }
7 }
8 true
9 }
10 let mut ret = 0;
11 for length in 3..=nums.len() {
12 for i in 0..=nums.len() - length {

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected