3 ms·
Oh, so I guess it is strictly O(m log m + log n) if m is the number of letters. You can theoretically get it to be O(m log m) using a hashmap (makes lookups O(1
by dbaupp 12y ago
Oh, so I guess it is strictly O(m log m + log n) if m is the number of letters. You can theoretically get it to be O(m log m) using a hashmap (makes lookups O(1)) or trie (lookups are O(m)).