leetcode-5344 有多少小于当前数字的数字 Python
2020-03-15 12:14
966 查看
方法一:
class Solution: def smallerNumbersThanCurrent(self, nums: List[int]) -> List[int]: return [sum(1 for j in range(len(nums)) if i > nums[j]) for i in nums]
方法二:
class Solution: def smallerNumbersThanCurrent(self, nums: List[int]) -> List[int]: res = [] count = 0 for i in range(len(nums)): for j in range(len(nums)): if nums[i]>nums[j]: count += 1 res.append(count) count = 0 return res
- 点赞
- 收藏
- 分享
- 文章举报
相关文章推荐
- LeetCode136.python实现: 只出现一次的数字☆
- 查看当前python环境是运行在多少位(64or32or128)模式下
- 【Python】利用当前时间、随机数产生一个唯一的数字
- Python和java题目:有四个数字:1、2、3、4,能组成多少个互不相同且无重复数字的三位数?各是多少?
- leetcode_[python/C++] 179. Largest Number(数字组合成最大数)
- [leetcode, python] Total Hamming Distance 多个数字之间的汉明距离
- HDU - 1541 Stars 树状数组 单点更新(求比当前数字大的数字有多少个)
- [Leetcode,python] Find All Numbers Disappeared in an Array 寻找数组中消失的数字
- 每日一题 LeetCode 有效的数字 Python实现
- LeetCode 402 移掉K位数字 Python
- [leetcode, python] Total Hamming Distance 多个数字之间的汉明距离
- [Python LeetCode]374. 猜数字大小(yangyang)
- [Leetcode,python] Find All Numbers Disappeared in an Array 寻找数组中消失的数字
- LeetCode 12. 整数转罗马数字 Python
- LeetCode--Excel Sheet Column Number(Excel表格的列名转数字)Python
- Python——有1、2、3、4个数字,能组成多少个互不相同且无重复数字的三位数?都是多少?
- [leetcode, python] Total Hamming Distance 多个数字之间的汉明距离
- LeetCode--Largest Number(最大数字)Python
- [Leetcode,python] Find All Numbers Disappeared in an Array 寻找数组中消失的数字
- python [LeetCode] 只出现一次的数字