목록코딩테스트연습 (60)
YJ의 새벽

1로 만들기 class Solution { public int solution(int[] num_list) { int answer = 0; for ( int i=0; i

문자열 반복해서 출력하기 간단하다. import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner sc = new Scanner(System.in); String str = sc.next(); int n = sc.nextInt(); String result=""; for ( int i=0; i

간단한 논리 연산. if 조건문 노가다 쓰고있다가. 어느정도 알고리즘을 발견했습니다. 하지만 문제이해를 100퍼센트 하지는 못했어요. public class Solution { public boolean solution(boolean x1, boolean x2, boolean x3, boolean x4) { if((x1 == true || x2 == true) && (x3 == true || x4 == true)){ return true; } else { return false; } } }

문자열 뒤집기. my_string 에서 s 부터 e 까지 문자열을 뽑아내 변수 선언, 뽑은 문자열의 순서를 반대로 바꾸어준다. 그후 뽑은 문자열과 바뀔 문자열을 replace. public class Solution { public String solution(String my_string, int s, int e) { String answer = ""; String val = my_string.substring(s,e); String val2= ""; for ( int j = val.length()-1 ; j>=0; j--) { val2 += val.charAt(j); } answer = my_string.replace(val,val2); return answer; } }