Created
July 12, 2018 08:57
-
-
Save youngdo212/8b3d9e59366cee84d52849fc09e3ca3d to your computer and use it in GitHub Desktop.
https://programmers.co.kr/learn/courses/30/lessons/12904/solution_groups?language=javascript&type=my
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function solution(s){ | |
let {length} = s; | |
while(length){ | |
for(let i = 0; i + length <= s.length; i++){ | |
if(isPalin(s.slice(i,i+length))) return length; | |
} | |
length-- | |
} | |
} | |
function isPalin(s){ | |
for(let i = 0, {length} = s; i < length/2; i++){ | |
if(s[i] !== s[length-1-i]) return false | |
} | |
return true; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
하드코딩...