Advertisement
momo2345

arithmatic

Jul 11th, 2020
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.30 KB | None | 0 0
  1. class Solution {
  2. public:
  3.     bool canMakeArithmeticProgression(vector<int>& arr) {
  4.        sort(arr.begin(),arr.end());
  5.        
  6.        int sample=arr[1]-arr[0];
  7.         for(int i=2;i<arr.size();i++){
  8.             if(arr[i]-arr[i-1]!=sample ) return false;
  9.         }
  10.         return true;
  11.     }
  12. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement