diff --git a/leetcode problems/Can_Make_Arithmetic_Progression_From_Sequence.cpp b/leetcode problems/Can_Make_Arithmetic_Progression_From_Sequence.cpp new file mode 100644 index 0000000..d2c3c2f --- /dev/null +++ b/leetcode problems/Can_Make_Arithmetic_Progression_From_Sequence.cpp @@ -0,0 +1,18 @@ +class Solution +{ +public: + bool canMakeArithmeticProgression(vector &arr) + { + sort(arr.begin(), arr.end()); + int n = arr.size(); + if (n == 0 or n == 1 or n == 2) + return 1; + int d = arr[0] - arr[1]; + for (int i = 0; i < n - 1; i++) + { + if (arr[i] - arr[i + 1] != d) + return 0; + } + return 1; + } +}; \ No newline at end of file