public class Solution { public int HeightChecker(int[] heights) { List<int> correctOrder = new List<int>(); int amountWrong = 0; foreach(int i in heights) { int iter = i; while (iter <= heights.Length){ iter++; if (heights[i] < heights[iter]) { int curr = heights[iter-1]; correctOrder.Insert(iter-1, correctOrder[heights[iter-1]]); correctOrder.Insert(iter, curr); } } } foreach(int i in heights) { if(heights[i] != correctOrder[i]){ amountWrong++; } } return amountWrong; }}