leetcode1365

Posted AsenYang

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了leetcode1365相关的知识,希望对你有一定的参考价值。

 1 class Solution:
 2     def smallerNumbersThanCurrent(self, nums: List[int]) -> List[int]:
 3         sorted_nums = sorted(nums)
 4         n = len(nums)
 5         index = 0
 6         dic = {}
 7         for i in range(n):
 8             cur = sorted_nums[i]
 9             if cur not in dic:
10                 dic[cur] = index
11             index += 1
12         result = []
13         for i in range(n):
14             cur = nums[i]
15             result.append(dic[cur])
16         return result

算法思路:hash

以上是关于leetcode1365的主要内容,如果未能解决你的问题,请参考以下文章

算法leetcode每日一练1365. 有多少小于当前数字的数字

算法leetcode每日一练1365. 有多少小于当前数字的数字

LeetCode-1365 How Many Numbers Are Smaller Than the Current Number Solution with python

[LeetCode] 1365. How Many Numbers Are Smaller Than the Current Number

LeetCode --- 1365. How Many Numbers Are Smaller Than the Current Number 解题报告

Leetcode 1365. How Many Numbers Are Smaller Than the Current Number