[CC150] Ch1.3 Remove duplicate in a string

1.3 Design an algorithm and write code to remove the duplicate characters in a string without using any additional buffer. NOTE: One or two additional variables are fine. An extra copy of the array is not.

"remove duplicate": make sure each character occurs at most once.
The only way to avoid additional buffer is search the string again and again... O(n^2)
Or we can use hash map or indicator array for achieving O(n)

Comments

Popular posts from this blog

Maximum Gap

[ITint5] Maximum Subarray for a Circular Array

[CC150] Chapter 8 Object-Oriented Design