Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: add missing elements and remove duplicates....and some more questions.

by davido (Cardinal)
on Apr 23, 2017 at 02:43 UTC ( [id://1188652]=note: print w/replies, xml ) Need Help??


in reply to add missing elements and remove duplicates....and some more questions.

Finding a min and a max can be done in linear time, as can generating a list with no duplicates and no gaps. And the algorithm can be adapted to work in constant space as well. Ask this person who did not care for your algorithm to explain the time complexity and space requirements of the solution that he or she considers better.

I suspect this is one of those exercises that is intended to demonstrate the flexibility of a hash, but the problem's specification yields itself better to a more specific, and more optimal algorithm.


Dave

  • Comment on Re: add missing elements and remove duplicates....and some more questions.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1188652]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (2)
As of 2024-04-25 19:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found