DE Shaw latest OA question,
Question
constraint are n=10^5 so cant go for N^2 and k<=10^9
Given an array of music type and int k
We have to return cost of mixing all types of music
mix(a,b)=k/(gcd(lcm(a,b),k))
eg: 4 5 6 , k=12
Mixing of 4,6 costs k/(gcd(lcm(4,6),k)
So ans will be mix(4,4),mix(5,5),mix(6,6),mix(4,5),mix(5,4),mix(4,6),mix(6,4),mix(5,6),mix(6,5)