1502. Can Make Arithmetic Progression From Sequence Easy
1/**
2 * [1502] Can Make Arithmetic Progression From Sequence
3 *
4 * A sequence of numbers is called an arithmetic progression if the difference between any two consecutive elements is the same.
5 * Given an array of numbers arr, return true if the array can be rearranged to form an arithmetic progression. Otherwise, return false.
6 *
7 * Example 1:
8 *
9 * Input: arr = [3,5,1]
10 * Output: true
11 * Explanation: We can reorder the elements as [1,3,5] or [5,3,1] with differences 2 and -2 respectively, between each consecutive elements.
12 *
13 * Example 2:
14 *
15 * Input: arr = [1,2,4]
16 * Output: false
17 * Explanation: There is no way to reorder the elements to obtain an arithmetic progression.
18 *
19 *
20 * Constraints:
21 *
22 * 2 <= arr.length <= 1000
23 * -10^6 <= arr[i] <= 10^6
24 *
25 */
26pub struct Solution {}
27
28// problem: https://leetcode.com/problems/can-make-arithmetic-progression-from-sequence/
29// discuss: https://leetcode.com/problems/can-make-arithmetic-progression-from-sequence/discuss/?currentPage=1&orderBy=most_votes&query=
30
31// submission codes start here
32
33impl Solution {
34 pub fn can_make_arithmetic_progression(arr: Vec<i32>) -> bool {
35 false
36 }
37}
38
39// submission codes end
40
41#[cfg(test)]
42mod tests {
43 use super::*;
44
45 #[test]
46 fn test_1502() {
47 }
48}
49
Back
© 2025 bowen.ge All Rights Reserved.