|
-
October 22nd, 2009, 09:56 AM
#1
Compacting an array in C++
Hi,
Hope someone can give the simplest solution , and maybe it can be in O(n) if it is possible with explanations.
I need a function that takes sorted int array , and a size , and returns a new compact array after removing the duplicated elements , and the new size.
It can be solved in O(n^2) also .
Example:
1 , 3, 7, 7, 8, 9, 9, 9, 10
and it will return :
1 , 3 , 7 , 8, 9, 10 and size 5
Thank you
Tags for this Thread
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
|