-
November 2nd, 2009, 11:41 AM
#16
Re: Array Duplicates
Originally Posted by monarch_dodra
The code isn't rocket science, that's for sure, but I feel it goes against the "don't write write-only code".
Well and the code has a major disdvantage. Its O(N*N), so it shouldn't be written at all really.
The standard alogithm for frequency counting uses a (hash) map and it's O(N) only. Just one scan of the input array is required. It makes a big difference for big inputs.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|