How to decide whether there is a duplicate in a string
1. use hashtable time O(n), space O(26)
2. use bitset time O(n), space O(26)
3. sort and find, time O(nlogn), space O(1)
4. use the msb of each char as bitvector O(n), O(1) (the length of string is bigger than 26)
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment