Almost Prime number

Problem:A no is said to be  k-Almost Prime Number if it  has exactly k prime factors (not necessary distinct). Your task is to complete the functionprintKAlmostPrimes which takes two argument k and N and prints the  first N numbers that are k prime. Problem Link

 

11827

 

10223

 

1225

 

11970

 

11121

 

12459

 

11466

There should be a better approach to improve the time complexity.

 

10533