← 返回 google 的题目列表Check if all array elements occur more than k times
类型:online_judge
google
Given an integer array, count the occurrences of each number and check if the occurrence of each number is greater than a given value k. Please write a function to solve this problem. The function should return a boolean indicating whether the condition is satisfied.
Input: An array of integers and an integer k.
Output: A boolean indicating if the count of occurrences of each number in the array is greater than k.
Test cases:
Input: [1, 2, 2, 3, 1, 1, 3, 3, 3], k = 1 Output: True
Input: [1, 2, 3, 4, 5], k = 0 Output: True
Input: [1, 1, 2, 2, 3, 4], k = 2 Output: False
Constraints: The array size is between 1 and 10^5, k is a non-negative integer not exceeding 100.
Example
Input
[1, 2, 2, 3, 1, 1, 3, 3, 3]
1