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(); } }
"Simplicity can't be bought later, it must be earned from the start" -- DB
Sunday, February 14, 2021
Leetcode Everyday: 1365. How Many Numbers Are Smaller Than the Current Number. Easy
Labels:
leetcode
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment