Company: Visa fte
Difficulty: medium
Smart Grid Energy Readings You are monitoring energy usage in a smart grid system and need to identify specific data patterns in the readings. Given an array of integers readings representing the energy readings over a period and an integer k , count the readings that are powers of k . In this context, a power of k refers to numbers that can be expressed as k raised to an integer power (e.g., k 0 , k 1 , k 2 , etc.). Input Format An array readings containing integer values representing energy readings An integer k representing the base number for power calculations Output Format Return an integer representing the count of readings that are powers of k. Constraints 1 ≤ readings.length ≤ 10 5 1 ≤ k ≤ 10 1 ≤ readings[i] ≤ 10 9 Note You are not expected to provide the most optimal solution, but a solution with time complexity not worse than O(readings.length 2 ) will fit within the execution time limit. Examples Input: readings = [1, 2, 4, 8, 3, 5] k = 2 Output: 4 The powers of 2 in the re