Consecutive k-Primes Time : Space : 1234567891011121314151617181920212223242526#include <vector>using namespace std;class PrimeConsec{private: static int countPrimeDiv(long long n) { if(n == 1) return 1; int res = 0; for(int i = 2; i * i <= n; i++) { if(n % i) continue; while(n % i == 0) { n /= i; res += 1; } } if(n != 1) res += 1; return res; }public: static int consecKprimes(int k, std::vector<long long> &arr) { for(auto& x : arr) x = countPrimeDiv(x); int res = 0; for(int i = 1; i < arr.size(); i++) res += arr[i] == k and arr[i-1] == k; return res; }};