본문 바로가기

Coding Test

(221)
[프로그래머스/자바] 약수의 합 import java.util.stream.*; class Solution { public int solution(int n) { return IntStream.range(1, n + 1).filter(i -> n % i == 0).sum(); } }
[프로그래머스/자바] 핸드폰 번호 가리기 class Solution { public String solution(String phone_number) { int length = phone_number.length() - 4; String answer = "*".repeat(length); answer += phone_number.substring(length); return answer; } }
[프로그래머스/자바] 문자열을 정수로 바꾸기 class Solution { public int solution(String s) { if (s.substring(0, 1).equals("-")) return 0 - Integer.parseInt(s.substring(1)); else if (s.substring(0, 1).equals("+")) return Integer.parseInt(s.substring(1)); else return Integer.parseInt(s); } }
[프로그래머스/자바] 나머지가 1이 되는 수 찾기 class Solution { public int solution(int n) { int num = n - 1; for(int i = 2; i
[프로그래머스/자바] 자연수 뒤집어 배열로 만들기 풀이1) class Solution { public int[] solution(long n) { StringBuffer sb = new StringBuffer("" + n); sb.reverse(); int[] arr = new int[sb.length()]; for(int i=0; i
[프로그래머스/자바] 2016년 class Solution { public String solution(int a, int b) { int[] month = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; String[] days = {"SUN","MON","TUE","WED","THU","FRI","SAT"}; int num = 4 + b; if(a != 1) { for(int i=0; i
[백준/자바] 18110 - solved.ac import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Arrays; public class Main { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int n = Integer.parseInt(br.readLine()); int[] arr = new int[n]; for(int i=0; i
[백준/자바] 11399 - ATM Arrays.sort()를 이용한 풀이 import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Arrays; import java.util.StringTokenizer; public class Main { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int N = Integer.parseInt(br.readLine()); int[] arr = new int[N]; Strin..