You are not logged in. Please login at to post your questions!


Help required in this question

Hi i am stucked in this problem 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

sandeep9's gravatar image

accept rate: 4%


Link not working dear, please re-check.

(26 Feb '17, 18:15) vijju123 ♦♦4★

All because of that '.' at the end, which many failed to notice!

(26 Feb '17, 22:54) utkarsh19974★

Thanks Utkarsh & Banshal :)

(01 Mar '17, 16:22) sandeep93★

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

bansal1232's gravatar image

accept rate: 16%

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) sandeep93★
Answer is hidden as author is suspended. Click here to view.

answered 26 Feb '17, 19:57

siddhu1796's gravatar image

accept rate: 0%

toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text]( "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported
  • mathemetical formulas in Latex between $ symbol

Question tags:


question asked: 26 Feb '17, 18:10

question was seen: 443 times

last updated: 01 Mar '17, 16:46