mirror of
https://github.com/donnemartin/interactive-coding-challenges.git
synced 2024-03-22 13:11:13 +08:00
Tweaked permutations challenge algorithm discussion.
This commit is contained in:
parent
d4d7c29c9d
commit
11bd2e9768
|
@ -64,7 +64,7 @@
|
|||
"source": [
|
||||
"## Algorithm: Compare Sorted Strings\n",
|
||||
"\n",
|
||||
"Anagrams contain the same strings but in different orders. This approach could be slow for large strings due to sorting.\n",
|
||||
"Permutations contain the same strings but in different orders. This approach could be slow for large strings due to sorting.\n",
|
||||
"\n",
|
||||
"* Sort both strings\n",
|
||||
"* If both sorted strings are equal\n",
|
||||
|
@ -74,7 +74,7 @@
|
|||
"\n",
|
||||
"Complexity:\n",
|
||||
"* Time: O(n log n) from the sort, in general\n",
|
||||
"* Space: Additional O(l + m) is created by the sorting algorithm, where l is the length of one string and m is the length of the other"
|
||||
"* Space: O(n)"
|
||||
]
|
||||
},
|
||||
{
|
||||
|
@ -121,7 +121,7 @@
|
|||
"\n",
|
||||
"Complexity:\n",
|
||||
"* Time: O(n)\n",
|
||||
"* Space: Additional O(m), where m is the number of unique characters in the hash map"
|
||||
"* Space: O(n)"
|
||||
]
|
||||
},
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue
Block a user