r/learnjavascript • • Sep 26 '22

Just solved a Palindrome problem with recursion!!

Post image
274 Upvotes

64 comments sorted by

View all comments

Show parent comments

0

u/[deleted] Sep 27 '22

[deleted]

7

u/[deleted] Sep 27 '22

It’s a solution that has a time complexity of O(n), which is the minimum required to solve this problem

0

u/[deleted] Sep 27 '22

[deleted]

-1

u/wischichr Sep 27 '22

Not true and big O is not a good measure in general. Run time complexity is just one metric to classify an algorithm and doesn't have much value on it's own.

In this case the palindrome example could be solved with an O(1) algorithm but it would still be slower than all other suggested solutions here.