mirror of
https://github.com/donnemartin/interactive-coding-challenges
synced 2026-01-03 16:08:02 +00:00
Tweaked permutations challenge algorithm discussion.
This commit is contained in:
@@ -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)"
|
||||
]
|
||||
},
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user