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