mirror of
https://github.com/donnemartin/interactive-coding-challenges
synced 2026-01-10 03:18:02 +00:00
Tweaked permutations challenge algorithm discussion.
This commit is contained in:
@@ -64,7 +64,7 @@
|
|||||||
"source": [
|
"source": [
|
||||||
"## Algorithm: Compare Sorted Strings\n",
|
"## Algorithm: Compare Sorted Strings\n",
|
||||||
"\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",
|
"\n",
|
||||||
"* Sort both strings\n",
|
"* Sort both strings\n",
|
||||||
"* If both sorted strings are equal\n",
|
"* If both sorted strings are equal\n",
|
||||||
@@ -74,7 +74,7 @@
|
|||||||
"\n",
|
"\n",
|
||||||
"Complexity:\n",
|
"Complexity:\n",
|
||||||
"* Time: O(n log n) from the sort, in general\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",
|
"\n",
|
||||||
"Complexity:\n",
|
"Complexity:\n",
|
||||||
"* Time: O(n)\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