Company: Oracle_23sep
Difficulty: medium
Valid keys Problem Description A number is defined as a valid key when it has exactly 3 positive divisors. For instance, 4 qualifies because its only divisors are 1, 2, and 4, while 6 does not, since it has 4 divisors: 1, 2, 3, and 6. Given an array keys of length n , for each 0 , count how many valid keys lie in the range [1, keys[i]] , inclusive on both ends. Note: a is called a divisor of b if there is an integer c such that a * c = b. Only positive integers are taken into account for counting divisors. Complete the function getValidKeyCount in the editor below. The function getValidKeyCount has the following parameter: vector keys : an array of integers. Returns: vector : an array of integers containing the answer for each query. vector getValidKeyCount(vector keys) { // Function body to be implemented } Examples Example 1: Input: keys = [5, 11] Output: [1, 2] Explanation: For keys[0] = 5 , the only valid key in the range [1, 5] is 4 (factors: 1, 2, 4). The count is 1. For keys[1]