mirror of
https://github.com/TheAlgorithms/JavaScript.git
synced 2025-07-05 16:26:47 +08:00
merge: Fix IsPalindrome Big-O analysis (#1054)
* Fix IsPalindrome Big-O analysis * Updated Documentation in README.md Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
This commit is contained in:
@ -299,6 +299,7 @@
|
||||
* [FormatPhoneNumber](String/FormatPhoneNumber.js)
|
||||
* [GenerateGUID](String/GenerateGUID.js)
|
||||
* [HammingDistance](String/HammingDistance.js)
|
||||
* [IsPalindrome](String/IsPalindrome.js)
|
||||
* [KMPPatternSearching](String/KMPPatternSearching.js)
|
||||
* [LevenshteinDistance](String/LevenshteinDistance.js)
|
||||
* [Lower](String/Lower.js)
|
||||
|
@ -10,7 +10,8 @@
|
||||
* Big-O Analysis
|
||||
* Time Complexity
|
||||
- O(N) on average and worst case scenario as input is traversed in linear fashion
|
||||
- O(N) on best case scenario, even when input has length of 1, because toString() method takes O(N)
|
||||
- O(1) on best case scenario if the input already is a string (otherwise toString() method takes O(N))
|
||||
and the first & last characters don't match, triggering an early return
|
||||
* Space Complexity
|
||||
- O(1)
|
||||
*/
|
||||
|
Reference in New Issue
Block a user