206 - 315 计算右侧小于当前元素的个数
Last updated
Was this helpful?
Last updated
Was this helpful?
给定一个整数数组 nums,按要求返回一个新数组 counts。数组 counts 有该性质: counts[i] 的值是 nums[i] 右侧小于 nums[i] 的元素的数量。
示例:
输入: [5,2,6,1] 输出: [2,1,1,0] 解释: 5 的右侧有 2 个更小的元素 (2 和 1). 2 的右侧仅有 1 个更小的元素 (1). 6 的右侧有 1 个更小的元素 (1). 1 的右侧有 0 个更小的元素.
光头大佬的解法不能通过,但评论中有解法可以通过。。
Runtime: 176 ms, faster than 40.67% of Python3 online submissions for Count of Smaller Numbers After Self.
Memory Usage: 17.1 MB, less than 37.50% of Python3 online submissions for Count of Smaller Numbers After Self.