public class Solution {
public int HeightChecker(int[] heights) {
int res = 0;
int[] sortedHeights = new int[heights.Length];
Array.Copy(heights,sortedHeights, heights.Length);
Array.Sort(sortedHeights);
for (int i = 0; i < heights.Length; i++)
{
if (sortedHeights[i] != heights[i])
{
res++;
}
}
return res;
}
}