leetcode

Solution to some Leetcode problems written in C++
git clone git://git.dimitrijedobrota.com/leetcode.git
Log | Files | Refs | README | LICENSE

1051.cpp (298B)


      1 class Solution {
      2   public:
      3     int heightChecker(vector<int> &heights) {
      4         int count = 0;
      5         vector<int> exp = heights;
      6         sort(exp.begin(), exp.end());
      7 
      8         for (int i = 0; i < heights.size(); i++)
      9             if (heights[i] != exp[i]) count++;
     10 
     11         return count;
     12     }
     13 };