题目标签:Sort
先排序,就很容易判定了,具体看code。
Java Solution:
Runtime: 1 ms, faster than 98.60%
Memory Usage: 38.9 MB, less than 92.87%
完成日期:8/11/2020
关键点:sort
class Solution { public boolean canMakeArithmeticProgression(int[] arr) { Arrays.sort(arr); int diff = arr[1] - arr[0]; for(int i=1; i<arr.length-1; i++) { if(arr[i] + diff != arr[i+1]) { return false; } } return true; } }
LeetCode 题目列表 - LeetCode Questions List
题目来源:https://leetcode.com/