class Solution { public String solution(String my_string) { String answer = ""; char[] arr = my_string.toCharArray(); for(int i=0; i= 'a' && arr[i]= 'A' && arr[i]
class Solution { public String solution(String cipher, int code) { int k = code -1; String answer = ""; char[] arr = cipher.toCharArray(); for(int i=k; i
class Solution { public int solution(String A, String B) { int answer = -1; StringBuilder sb = new StringBuilder(A); for(int i=0; i
배열사용 풀이 import java.util.*; class Solution { public int[] solution(int n, int[] numlist) { int[] arr = new int[numlist.length]; // arr 배열 선언(길이:numlist.length) int count = 0; for(int i = 0; i
// import java.util.regex.Pattern; import java.util.regex.Pattern; class Solution { public boolean solution(String s) { boolean answer = false; if(s.length() == 4 || s.length() == 6){ if(Pattern.matches("[0-9]+", s)){ answer = true; } } return answer; } } Pattern.matches : 문자열 검증 문자열 s가 "0-9"로만 이루어져 있는지 검증
class Solution { public String solution(String s) { String answer = ""; if(s.length() % 2 == 1) { answer = s.substring(s.length() / 2, s.length() / 2 + 1); } else { answer = s.substring(s.length() / 2 - 1, s.length() / 2 + 1); } return answer; } } substring(a,b) : a이상 b미만의 index를 자름. Sting메서드