mirror of
https://github.com/youngyangyang04/leetcode-master.git
synced 2025-07-06 15:09:40 +08:00
fix: Update 1365,建议不使用built-in func作为var name
题解中使用`hash`作为变量名,而hash本身也是python3的built-in函数,故建议更改变量名
This commit is contained in:
@ -144,13 +144,13 @@ public int[] smallerNumbersThanCurrent(int[] nums) {
|
||||
class Solution:
|
||||
def smallerNumbersThanCurrent(self, nums: List[int]) -> List[int]:
|
||||
res = nums[:]
|
||||
hash = dict()
|
||||
hash_dict = dict()
|
||||
res.sort() # 从小到大排序之后,元素下标就是小于当前数字的数字
|
||||
for i, num in enumerate(res):
|
||||
if num not in hash.keys(): # 遇到了相同的数字,那么不需要更新该 number 的情况
|
||||
hash[num] = i
|
||||
if num not in hash_dict.keys(): # 遇到了相同的数字,那么不需要更新该 number 的情况
|
||||
hash_dict[num] = i
|
||||
for i, num in enumerate(nums):
|
||||
res[i] = hash[num]
|
||||
res[i] = hash_dict[num]
|
||||
return res
|
||||
```
|
||||
|
||||
|
Reference in New Issue
Block a user