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

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

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; } }

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

프로그래머스 - 원소들의 곱과 합

class Solution { public int solution(int[] num_list) { int sum = 0; int mul = 1; for(int i = 0; i mul){ return 1; }else{ return 0; } } }

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

프로그래머스 - 주사위 게임 2

class Solution { public int solution(int a, int b, int c) { if (a == b && b == c) { return (a + b + c) * (a * a + b * b + c * c) * (a * a * a + b * b * b + c * c * c); } else if (a == b || b == c || c == a) { return (a + b + c) * (a * a + b * b + c * c); } else { return a + b + c; } } }

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

프로그래머스 - 등차수열의 특정한 항만 더하기

class Solution { public int solution(int a, int d, boolean[] included) { int answer = 0; int[] arr = new int[included.length]; arr[0] = a; for(int i = 0; i = 1) { arr[i] = arr[i - 1] + d; } if(included[i]){ answer += arr[i]; } } return answer; } }

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

프로그래머스 - 코드 처리하기

class Solution { public String solution(String code) { String answer = ""; Boolean mode = false; for(int i = 0; i < code.length(); i++){ if(code.charAt(i) == '1' && !mode){ mode = true; }else if(code.charAt(i) == '1' && mode){ mode = false; } if (i % 2 == 0 && !mode && code.charAt(i) != '1') { answer += code.charAt(i); }else if( i % 2 == 1 && mode && code.charAt(i) != '1') { answer += code.charA..

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

프로그래머스 - flag에 따라 다른 값 반환하기

class Solution { public int solution(int a, int b, boolean flag) { int answer = 0; if(flag){ answer = a + b; }else{ answer = a - b; } return answer; } }

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

프로그래머스 - 조건 문자열

class Solution { public int solution(String ineq, String eq, int n, int m) { int answer = 0; if(ineq.equals(">") && eq.equals("=")){ if(n >= m){ answer = 1; }else{ answer = 0; } }else if(ineq.equals("") && eq.equals("!")){ if(n > m){ answer = 1; }else{ answer = 0; } }else if(ineq.equals("

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

프로그래머스 - 홀짝에 따라 다른 값 반환하기

HTML 삽입 미리보기할 수 없는 소스 class Solution { public int solution(int n) { int answer = 0; if(n % 2 == 1){ while(n>=1){ answer += n; n = n-2; } }else{ while(n>1){ answer += n*n; n = n-2; } } return answer; } }

강맹석
'분류 전체보기' 카테고리의 글 목록 (36 Page)