pawan kumar
I am a Good Person.
I am a Good Person.
is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.
CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.
Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.
Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.
First make a sieve of 10^5 according to constraints given.Also make a hash of given primes.Now take a variable, gcd_val and then find gcd of all elements. Now divide the array elements by this gcd_val. Now find each elements factorization, and check whether each elements factor is available in the hash or not. If any element's factor of given array is not in the hash,then print as "not possible", else print "possible".
- pawan kumar July 31, 2016Time complexity - O(nlogn)
Space complexity - O(n+k)
as per constraints - 1<=arr[i],n,k<=10^5
Example:1 -arr[]={ 7,14,21 }
primes[]={2,3}
gcd_val = 7
after dividing by gcd_val = 7, arr[]={1,2,3}
Example:2 arr[]={2,4,6}
primes[]={3}
gcd_val = 2
after dividing by gcd_val=2, arr[]={1,2,3}
here 2 is not in our hash, so "not possible".
** If anyone find anything wrong with my approach, feel free to correct me...:) **