Skip to content

Commit bbbf343

Browse files
appgurueugithub-actions
and
github-actions
authored
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>
1 parent 1b64ba6 commit bbbf343

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

DIRECTORY.md

+1
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

+2-1
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)