MN
BAN USER
Comments (8)
Reputation 0
Page:
1
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
0
of 0 vote
ok... let's work through one example here.
suppose R = {1 to 10^6} and Arr = [1,2,10,100,10^4, 10^6,10^6,10^4}.
you get n=8 and N = 10^6
now because of the fact you use "if(a[a[i]-1]==a[i])" you need Arr to be accessible upto N.
you are right you always need constant space but that could be at most N. I don't think this would qualify for a O(1) solution.
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
Page:
1
CareerCup is the world's biggest and best source for software engineering interview preparation. See all our resources.
@rohith good work
- MN November 13, 2010