Company: Nasdaq_18oct
Difficulty: medium
Find Power Problem Description Given an integer max_val and another integer a , return the biggest integer b such that a^b ≤ max_val . As a reminder: a^b = a * a * a * ... (a multiplied b times). You need to implement the function findPower with the following signature: /** * @param max_val the maximum authorized value. * @param a the value that will be raised to a specific power. * @return the biggest power value that respects the specified equation. */ int findPower(int max_val, int a) { // Write your code here } Examples Example 1: Input: max_val = 33, a = 2 Output: 5 Explanation: For a = 2 and max_val = 33 : 2^0 = 1 2^1 = 2 2^2 = 4 2^3 = 8 2^4 = 16 2^5 = 32 ( 32 ≤ 33 ) 2^6 = 64 ( 64 > 33 ) The biggest integer b such that 2^b ≤ 33 is 5 . Constraints 1 ≤ max_val ≤ 2,000,000,000 2 ≤ a ≤ 2,000,000,000 Available RAM: 512MB Timeout: 1 second