fix: Update 1365,建议不使用built-in func作为var name

题解中使用`hash`作为变量名,而hash本身也是python3的built-in函数,故建议更改变量名
This commit is contained in:
Yuan Yuan
2024-12-04 12:33:40 -06:00
committed by GitHub
parent 5b94b44864
commit 14223a2fa6

View File

@ -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
```