python/CodeChallenge_25.py

19 lines
451 B
Python

'''
Given an array of integers nums and an integer k, return an amount of integers in array are larger than the k.
Example 1
Input:
[9, 10, 2, 3, 55, 76, 12, 6]; k = 7
Output:
5
'''
class Solution(object):
def solve(self, nums: list[int], k: int) -> int:
count = 0
for num in nums:
if num > k:
count += 1
return count
s = Solution()
print(s.solve([9, 10, 2, 3, 55, 76, 12, 6], 7)) # Output: 5