Skip to content

Commit 74c59d5

Browse files
authored
Fix IsPalindrome Big-O analysis
1 parent 1b64ba6 commit 74c59d5

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

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)