• Skip to primary navigation
  • Skip to content
  • Skip to footer
zhicheng xie's demo blog
  • Quick-Start Guide

    Your Name

    I am an amazing person.

    • Somewhere

    Can Make Arithmetic Progression From Sequence

    less than 1 minute read

    <-E 1502> Can Make Arithmetic Progression From Sequence

    class Solution {
    public:
        bool canMakeArithmeticProgression(vector<int>& arr) {
            sort(arr.begin(), arr.end());
            int differ = arr[1] - arr[0];
            for(int i = 2; i < arr.size(); i++) {
                if((arr[i] - arr[i - 1]) != differ)
                    return false;
            }
            return true;
        }
    };
    

    Tags: Algorithms, C++, Leetcode

    Updated: November 20, 2020

    Share on

    Twitter Facebook LinkedIn
    Previous Next

    You may also enjoy

    Decode Ways

    less than 1 minute read

    <-M 91> Decode Ways

    Word Break

    less than 1 minute read

    <-H 139> Word Break

    Distinct Subsequences

    less than 1 minute read

    <-H 115> Distinct Subsequences

    Edit Distance

    less than 1 minute read

    <-H 72> Edit Distance

    • Follow:
    • Feed
    © 2023 zhicheng xie's blog. Powered by Jekyll & Minimal Mistakes.