➜ 코딩 테스트/프로그래머스

프로그래머스 - 수열과 구간 쿼리 2

class Solution { public int[] solution(int[] arr, int[][] queries) { int[] answer = new int[queries.length]; for (int i = 0; i k) { min = Math.min(min, arr[j]); check = true; } } if(check){ answer[i] = min;..

➜ 코딩 테스트/프로그래머스

프로그래머스 - 수열과 구간 쿼리 3

class Solution { public int[] solution(int[] arr, int[][] queries) { for(int i = 0; i < queries.length; i++){ int[] query = queries[i]; int a = query[0]; int b = query[1]; int temp = arr[a]; arr[a] = arr[b]; arr[b] = temp; } return arr; } }

➜ 코딩 테스트/프로그래머스

프로그래머스 - 수 조작하기1

class Solution { public int solution(int n, String control) { int answer = 0; String[] controlarr = new String[control.length()]; for(int i = 0; i < control.length(); i++){ controlarr[i] = String.valueOf(control.charAt(i)); } for(int j = 0; j < control.length(); j++){ if(controlarr[j].equals("w")){ n += 1; }else if(controlarr[j].equals("s")){ n -= 1; }else if(controlarr[j].equals("d")){ n += 10;..

➜ 코딩 테스트/프로그래머스

프로그래머스 - 마지막 두 원소

class Solution { public static int[] solution(int[] num_list) { int[] result = new int[0]; if(num_list.length > 1) { int last = num_list[num_list.length - 1]; int prev = num_list[num_list.length - 2]; if (last > prev) { result = new int[num_list.length + 1]; System.arraycopy(num_list, 0, result, 0, num_list.length); result[num_list.length] = last - prev; } else { result = new int[num_list.length..

➜ 코딩 테스트/프로그래머스

프로그래머스 - n보다 커질 때까지 더하기

class Solution { public int solution(int[] numbers, int n) { int answer = 0; int sum = 0; for(int i = 0; i n){ answer = sum; break; } } return answer; } }

➜ 코딩 테스트/프로그래머스

프로그래머스 - 문자열로 변환

class Solution { public String solution(int n) { String answer = ""; answer = Integer.toString(n); return answer; } }

➜ 코딩 테스트/프로그래머스

프로그래머스 - 부분 문자열인지 확인하기

class Solution { public int solution(String my_string, String target) { if(my_string.contains(target)) { return 1; }else{ return 0; } } }

➜ 코딩 테스트/프로그래머스

프로그래머스 - 문자열을 정수로 변환하기

class Solution { public int solution(String n_str) { return Integer.parseInt(n_str); } }

➜ 코딩 테스트/프로그래머스

프로그래머스 - 조건에 맞게 수열 변환하기 1

class Solution { public int[] solution(int[] arr) { int[] answer = new int[arr.length]; for(int i = 0; i = 50 && arr[i] % 2 == 0 ){ answer[i] = arr[i] / 2; }else if( arr[i] 50 && arr[i] % 2 == 1){ answer[i] = arr[i]; } } return answer; } }

➜ 코딩 테스트/프로그래머스

프로그래머스 - 이어 붙인 수

class Solution { public int solution(int[] num_list) { String odd = ""; String even = ""; int intodd = 0; int inteven = 0; for(int i = 0; i < num_list.length; i++){ if(num_list[i] % 2 == 1){ odd += num_list[i]; }else if (num_list[i] % 2 == 0){ even += num_list[i]; } } intodd = Integer.parseInt(odd); inteven = Integer.parseInt(even); return intodd + inteven; } }

강맹석
'➜ 코딩 테스트' 카테고리의 글 목록 (33 Page)