본문 바로가기

Coding Test

(221)
[프로그래머스/자바] 문자열 뒤집기 class Solution { public String solution(String my_string) { String answer = ""; for(int i=my_string.length()-1; i>=0; i--){ answer += my_string.charAt(i); } return answer; } } class Solution { public String solution(String my_string) { StringBuilder sb = new StringBuilder(); sb.append(my_string); return sb.reverse().toString(); } } StringBuilder를 사용하여 푸는 방법 class Solution { public String solutio..
[프로그래머스/자바] 양꼬치 class Solution { public int solution(int n, int k) { int answer = n*12000+k*2000; if(n>=10){ answer -= 2000*(n/10); } return answer; } } class Solution { public int solution(int n, int k) { return n * 12000 + k * 2000 - (n / 10 * 2000); } }
[프로그래머스/자바] 배열의 평균 값 class Solution { public double solution(int[] numbers) { double answer = 0; for(int i=0; i
[프로그래머스/자바] 짝수의 합 class Solution { public int solution(int n) { int answer = 0; for(int i=2; i e % 2 == 0) .sum(); } } 다른 분의 풀이. 참고하고 싶어서 가져왔다.
[프로그래머스/자바] 각도기 class Solution { public int solution(int angle) { if(0
[프로그래머스/자바] 두 수의 나눗셈 class Solution { public int solution(int num1, int num2) { return num1*1000/num2; } }
[프로그래머스/자바] 나이 출력 class Solution { public int solution(int age) { return 2023-age; } } class Solution { public int solution(int age) { int year = 2022; return year-age+1; } }
[프로그래머스/자바] 두 수의 합 class Solution { public int solution(int num1, int num2) { return num1+num2; } }