715. Z-Score

Given an array of integers marks containing the marks of a student in each subject and a multiplicative factor k. Return the Z-Score of the student.

Z-Score is defined as the maximum value of x, where the student has at least x subjects where they have scored at least x * k.

Example 1:

Input: marks = [62, 69, 79, 85, 45], k = 20

Output: 3

Explanation: Number of subjects with marks >= 3 * k = 3 * 20 = 60 -> [62, 69, 79, 85] = 4

Number of subjects with marks >= 4 * k = 4 * 20 = 80 -> [85] = 1

Thus, the maximum Z-Score is 3.

Example 2:

Input: marks = [93, 64, 91, 85], k = 45

Output: 2

Explanation: Number of subjects with marks >= 2 * k = 2 * 45 = 90 -> [93, 91] = 2

Number of subjects with marks >= 3 * k = 3 * 45 = 135 -> [ ] = 0

Thus, the maximum Z-Score is 2.

Still unsure what the problem is asking ?

Let’s go through a few more examples, step by step, to make it clearer.

Constraints:

  • n == Number of subjects
  • 1 <= n <= 105
  • 0 <= marks[i] <= 100
  • 1 <= k <= 100

Fun Facts

0
class Solution {
public:
int ZScore(vector<int>& marks, int k) {
 
}
};
Test Case

Input:

K
Marks