i have thought a lot on this. but not getting O(n) solution. given n URL's and you have to find the unique URL in that (if there is any). you have to print that URL. thanks. O(n2) solution is a stupid solution, some O(n) is acheivable, but not getting how can it be O(n). i have lastly thoguht about tries. can it be like this ? some related to tries ? thanks alot in advance.
nitin1
15
Master Poster
Recommended Answers
Jump to PostYou need to think of a way that you only look at each entry in the list once, and at the end of it know the answer, or at least can find it very quickly.
How would you do this on paper? If I read out a list of words …
Jump to Postsome O(n) is acheivable, but not getting how can it be O(n)
I can immediately think of an O(mn) solution where m represents the length of these strings, but strictly O(n) kind of ignores the fact that you're dealing with collections of characters or assumes that some constant …
Jump to PostPerhaps we use different notations. I class O(n) and O(mn) and indeed O(any multiple of n at all) as all being O(n).
All 10 Replies
Moschops
683
Practically a Master Poster
Featured Poster
deceptikon
1,790
Code Sniper
Team Colleague
Featured Poster
Moschops
683
Practically a Master Poster
Featured Poster
nitin1
15
Master Poster
deceptikon
1,790
Code Sniper
Team Colleague
Featured Poster
nitin1
15
Master Poster
Moschops
683
Practically a Master Poster
Featured Poster
deceptikon
1,790
Code Sniper
Team Colleague
Featured Poster
nitin1
15
Master Poster
deceptikon
1,790
Code Sniper
Team Colleague
Featured Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.