Hi i am stucked in this problem https://www.hackerrank.com/contests/h42finals/challenges/mathematicalgraph. Can anyone suggest an approach.. I tried to calculate all the divisors of each no upto 10^6,but that's a bit slow. What can be a faster approach to solve this ? asked 26 Feb '17, 18:10

See My Solution Here i just used a concept of DP, In which firstly i sort all the array in ascending order. After that i visit all the numbers that can be divisible by that particular number. But the question is asking about the isolated number so i used a flag variable to check is there number has been visited so far or not. If i don't found any number that aren't given in arr[] and aslo not a factor of my first number then it means that there exist no factor of that particular element. I hope you will get my logic. Otherwise just debug my code to know how it is working. If you have any doubt then feel free to comment there. answered 27 Feb '17, 01:13
I got it :),This idea didn't came to my mind as say if all the no's are same say 2 & N = 10^5,then the algo will time out..But now on reading the problem statment carefully,i am banging my head :(...Thanks a lot again :)
(01 Mar '17, 16:46)

Answer is hidden as author is suspended. Click here to view.
answered 26 Feb '17, 19:57

Link not working dear, please recheck.
https://www.hackerrank.com/contests/h42finals/challenges/mathematicalgraph
All because of that '.' at the end, which many failed to notice!
Thanks Utkarsh & Banshal :)