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 };