Created
July 7, 2020 10:50
-
-
Save dalcon10028/453338bcf8d6e9ae38019500dd4a7633 to your computer and use it in GitHub Desktop.
프로그래머스 코딩테스트 연습 Level1 - 가운데 글자 가져오기 [ Java ]
This file contains hidden or 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
class Solution { | |
public String solution(String s) { | |
int half = s.length()/2; | |
return s.length()%2==0 ? s.substring(half-1, half+1) : s.substring(half,half+1); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment