Problem · Array

Count Powers of K (MLE)

Learn this problem
EasyQuora logoQuoraINTERNOA

Problem statement

Given an array and a value k, find the count of numbers in the array that are powers of k. For example, if arr = [11, 121, 10] and k = 11, the result would be 2.

Function

countPowersOfK(arr: int[], k: int) → int

Examples

Example 1

arr = [11, 121, 10]k = 11return = 2
🐿️

More Quora problems

drafts saved locally
public int countPowersOfK(int[] arr, int k) {
  // write your code here
}
arr[11, 121, 10]
k11
expected2
checking account