×

# Find unique numbers from series without breaking order.

 0 1 Hi, I'm new to codechef. Please assist me if its repeative post. I'm C++/STL developer and looking for: finding unique numbers from series on integer number wihtout changing its order. e.g: i/p: 10,4,3,6,1,0,4,4,4,10,5,9,0,6,15,.... o/p(expected result): 10,4,3,6,1,0,5,9,15,.... Constraint: - time complexity should not be worst(N^2). Need to solve it in less time. - memory is adequate. - appricieate, if you can explain about STL containers or algorithm I must use to resolve this problem. asked 01 Apr '15, 15:19 0★vgg25 13●3 accept rate: 0%

 0  for : i 1 to N if(element does not exist in HashSet) add to hash set and print  Complexity O(N) answered 02 Apr '15, 00:07 46●2 accept rate: 33%

### You can add all numbers in a hashset and then print the set

Time Complexity : No of elements.
Memory : No of unique elements.

1547
accept rate: 0%

Thnx sidhartha4444 for your prompt reply but unorder_set will break series ordering.

with unorder_set o/p : 0 1 3 15 4 5 6 9 10.

This is incorrect.

NOTE: I presuming unorder_set is equivalent to hash_set.

(01 Apr '15, 16:44) 0★
 0 Thnx sidhartha4444 for your prompt reply but unorder_set will break series ordering. with unorder_set o/p : 0 1 3 15 4 5 6 9 10. This is incorrect. answered 01 Apr '15, 16:19 0★vgg25 13●3 accept rate: 0%
 toggle preview community wiki:
Preview

By Email:

Markdown Basics

• *italic* or _italic_
• **bold** or __bold__
• image?![alt text](/path/img.jpg "title")
• numbered list: 1. Foo 2. Bar
• to add a line break simply add two spaces to where you would like the new line to be.
• basic HTML tags are also supported
• mathemetical formulas in Latex between \$ symbol

Question tags:

×37
×22
×9
×3

question asked: 01 Apr '15, 15:19

question was seen: 781 times

last updated: 02 Apr '15, 00:09