Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit d11e6a5

Browse files
committed
Add solution #5
1 parent 74105b4 commit d11e6a5

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

0005-longest-palindromic-substring.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,11 @@ var longestPalindrome = function(s) {
1414
let result = '';
1515

1616
for (let i = 0; i < s.length; i++) {
17-
let palindrome1 = getExtendedPalindrome(s, i, i);
18-
let palindrome2 = getExtendedPalindrome(s, i, i + 1);
19-
let longerPalindrome = palindrome1.length > palindrome2.length
20-
? palindrome1 : palindrome2;
17+
const palindrome1 = getExtendedPalindrome(s, i, i);
18+
const palindrome2 = getExtendedPalindrome(s, i, i + 1);
19+
const longerPalindrome = palindrome1.length > palindrome2.length
20+
? palindrome1
21+
: palindrome2;
2122

2223
if (longerPalindrome.length > result.length) {
2324
result = longerPalindrome;

0 commit comments

Comments
 (0)