public class Solution { public int[] SmallerNumbersThanCurrent(int[] nums) { var sorted = nums.OrderBy(n => n).ToArray(); var smallCounts = new ListSource: https://leetcode.com/problems/how-many-numbers-are-smaller-than-the-current-number/(); for (var i = 0; i < nums.Length; ++i) { var count = Array.IndexOf(sorted, nums[i]); smallCounts.Add(count); } return smallCounts.ToArray(); } }
No comments:
Post a Comment