본문 바로가기

Coding Test

(221)
[프로그래머스/자바] 조건에 맞게 수열 변환하기 1 class Solution { public int[] solution(int[] arr) { for(int i=0; i= 50 && arr[i] % 2== 0) { arr[i] /= 2; } else if(arr[i] < 50 && arr[i] % 2 != 0) { arr[i] *= 2; } } return arr; } }
[프로그래머스/자바] 수 조작하기 1 class Solution { public int solution(int n, String control) { char[] array = control.toCharArray(); for(char c : array) { if(c == 'w') n++; else if(c == 's') n--; else if(c == 'd') n += 10; else n -= 10; } return n; } }
[프로그래머스/자바] n 번째 원소부터 import java.util.Arrays; class Solution { public int[] solution(int[] num_list, int n) { return Arrays.copyOfRange(num_list, n - 1, num_list.length); } }
[프로그래머스/자바] 세균 증식 class Solution { public int solution(int n, int t) { return n * (int) Math.pow(2, t); } }
[프로그래머스/자바] 옷가게 할인받기 class Solution { public int solution(int price) { if(price >= 500000) { return (int) (price * 0.8); } else if(price >= 300000) { return (int) (price * 0.9); } else if(price >= 100000) { return (int) (price * 0.95); } else { return price; } } } class Solution { public int solution(int price) { int answer = 0; if(price>=500000) return (int)(price*0.8); if(price>=300000) return (int)(price*0.9); if..
[프로그래머스/자바] 부분 문자열인지 확인하기 class Solution { public int solution(String my_string, String target) { return my_string.contains(target) ? 1 : 0; } }
[프로그래머스/자바] 기능개발 import java.util.ArrayList; import java.util.LinkedList; import java.util.List; import java.util.Queue; class Solution { public int[] solution(int[] progresses, int[] speeds) { Queue queue = new LinkedList(); for(int i=0; i= queue.peek()) { queue.poll(); count++; } list.add(count); } int[] result = new int[list.size()]; for(int i=0; i
[프로그래머스/자바] 문자 반복 출력하기 class Solution { public String solution(String my_string, int n) { String answer = ""; for(int i=0; i