If O(1) extra memory is allowed: O(n) time and O(1) space. Input data not stored. https://github.com/swagatata/ds_and_algos/blob/master/cpp/trivia/remove_duplicates_one_pass.cpp
See also: No extra memory except input buffer: O(n log n) time O(n) space (can't do better than this). https://github.com/swagatata/ds_and_algos/blob/master/cpp/trivia/remove_duplicates_without_extra_memory.cpp The code is terse but completely correct. Will leave you guys to figure it out by googling. :) Compile and run on linux with g++ -std=c++0x filename.cpp Use a g++ version > 4.5. Note: DevC++ uses an obsolete compiler. Will not work on it. -- DK -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To view this discussion on the web visit https://groups.google.com/d/msg/algogeeks/-/MxRwQO9hgPcJ. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
