[CC150] Ch1.1 Check duplicate in a string

1.1 Implement an algorithm to determine if a string has all unique characters What if you can not use additional data structures?

The first thought is to use hash table.
If additional data structures are not allowed, we may use a large array corresponding to all possible characters. The array size depends on the characters sets (ASCII has 256 characters, for example). Both methods takes O(n) time.

Comments

Popular posts from this blog

Maximum Gap

[ITint5] Maximum Subarray for a Circular Array

[CC150] Chapter 4 Trees and Graphs