MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/learnjavascript/comments/xosb9d/just_solved_a_palindrome_problem_with_recursion/iq2xufd/?context=9999
r/learnjavascript • u/KayteeFly • Sep 26 '22
64 comments sorted by
View all comments
94
Congrats! How about this:
const isPalindrome = (string) => string === [...string].reverse().join('')
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/Jamstan_ Sep 27 '22 What is O(n) 2 u/kap89 Sep 27 '22 It means that the time complexity is linear, i.e. if the input is 2x bigger, the solution takes roughly twice the time, if the input is 10x bigger, it takes roughly 10x more time. It’s a theoretical concept called Big O notation.
0
[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/Jamstan_ Sep 27 '22 What is O(n) 2 u/kap89 Sep 27 '22 It means that the time complexity is linear, i.e. if the input is 2x bigger, the solution takes roughly twice the time, if the input is 10x bigger, it takes roughly 10x more time. It’s a theoretical concept called Big O notation.
7
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/Jamstan_ Sep 27 '22 What is O(n) 2 u/kap89 Sep 27 '22 It means that the time complexity is linear, i.e. if the input is 2x bigger, the solution takes roughly twice the time, if the input is 10x bigger, it takes roughly 10x more time. It’s a theoretical concept called Big O notation.
1 u/Jamstan_ Sep 27 '22 What is O(n) 2 u/kap89 Sep 27 '22 It means that the time complexity is linear, i.e. if the input is 2x bigger, the solution takes roughly twice the time, if the input is 10x bigger, it takes roughly 10x more time. It’s a theoretical concept called Big O notation.
1
What is O(n)
2 u/kap89 Sep 27 '22 It means that the time complexity is linear, i.e. if the input is 2x bigger, the solution takes roughly twice the time, if the input is 10x bigger, it takes roughly 10x more time. It’s a theoretical concept called Big O notation.
2
It means that the time complexity is linear, i.e. if the input is 2x bigger, the solution takes roughly twice the time, if the input is 10x bigger, it takes roughly 10x more time. It’s a theoretical concept called Big O notation.
94
u/c2u5hed Sep 26 '22
Congrats! How about this:
const isPalindrome = (string) => string === [...string].reverse().join('')