Skip to content

Commit bbbf343

Browse files
appgurueugithub-actions
andauthored
merge: Fix IsPalindrome Big-O analysis (TheAlgorithms#1054)
* Fix IsPalindrome Big-O analysis * Updated Documentation in README.md Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
1 parent 1b64ba6 commit bbbf343

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

DIRECTORY.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,7 @@
299299
* [FormatPhoneNumber](String/FormatPhoneNumber.js)
300300
* [GenerateGUID](String/GenerateGUID.js)
301301
* [HammingDistance](String/HammingDistance.js)
302+
* [IsPalindrome](String/IsPalindrome.js)
302303
* [KMPPatternSearching](String/KMPPatternSearching.js)
303304
* [LevenshteinDistance](String/LevenshteinDistance.js)
304305
* [Lower](String/Lower.js)

String/IsPalindrome.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010
* Big-O Analysis
1111
* Time Complexity
1212
- O(N) on average and worst case scenario as input is traversed in linear fashion
13-
- O(N) on best case scenario, even when input has length of 1, because toString() method takes O(N)
13+
- O(1) on best case scenario if the input already is a string (otherwise toString() method takes O(N))
14+
and the first & last characters don't match, triggering an early return
1415
* Space Complexity
1516
- O(1)
1617
*/

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy