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

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

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

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

프로그래머스 - 공배수

HTML 삽입 미리보기할 수 없는 소스 class Solution { public int solution(int number, int n, int m) { int answer = 0; if(number % n == 0 && number % m == 0){ answer = 1; }else{ answer = 0; } return answer; } }

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

프로그래머스 - n의 배수

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

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

프로그래머스 - 두 수의 연산값 비교하기

HTML 삽입 미리보기할 수 없는 소스 class Solution { public int solution(int a, int b) { int num = Integer.parseInt("" + a + b); if(num >= 2 * a * b){ return num; } else{ return 2 * a * b; } } }

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