Height Checker - c# 3 line of code (LINQ)

Easy to understand code by using LINQ

public class Solution {
    public int HeightChecker(int[] heights) {
            var orderedHeights = new List<int>(heights);
            orderedHeights.Sort();

            return heights.Where((t, i) => t != orderedHeights[i]).Count();
    }
}
Comments (0)