Algorithm/프로그래머스
2023.05.07
import java.util.Arrays; import java.util.Comparator; import java.util.stream.IntStream; class Solution { public int[] solution(int start, int end) { Integer[] ints = IntStream.rangeClosed(end, start).boxed().toArray(Integer[]::new); Arrays.sort(ints, Comparator.reverseOrder()); return Arrays.stream(ints).mapToInt(i -> i).toArray(); } } import java.util.stream.*; import java.util.*; class Soluti..
Algorithm/프로그래머스
2023.05.07
import java.util.ArrayList; import java.util.List; class Solution { public int[] solution(int n, int k) { List list = new ArrayList(); for (int i = 1; i i % k == 0).toArray(); } }
Algorithm/프로그래머스
2023.05.07
import java.util.Arrays; import java.util.stream.Collectors; class Solution { public String solution(String my_string, int[] indices) { String[] split = my_string.split(""); for (int index : indices) { split[index] = ""; } return Arrays.asList(split).stream().collect(Collectors.joining()); } }
Algorithm/프로그래머스
2023.04.21
import java.util.Arrays; import java.util.stream.Collectors; class Solution { public String solution(String my_string, String overwrite_string, int s) { String answer = ""; String[] split = my_string.split(""); for (int i = 0; i < overwrite_string.length(); i++) { split[i+s] = String.valueOf(overwrite_string.charAt(i)); } return Arrays.stream(split).collect(Collectors.joining()); } }
Algorithm/프로그래머스
2023.04.17
class Solution { public int[] solution(int[][] score) { int[] answer = new int[score.length]; int ranking = 1; for (int i = 0; i < score.length; i++) { for (int j = 0; j < score.length; j++) { if (score[i][0] + score[i][1] < score[j][0] + score[j][1]) { ranking++; } else if(score[i][0] + score[i][1] == score[j][0] + score[j][1]){ continue; } } answer[i] = ranking; ranking=1; } return answer; } }
Algorithm/프로그래머스
2023.04.17
public String solution(String[] id_pw, String[][] db) { int db_size = db.length; for (int i = 0; i < db_size; i++) { if (db[i][0].equals(id_pw[0])) { if(db[i][1].equals(id_pw[1])) { return "login"; } return "wrong pw"; } } return "fail"; }
Algorithm/프로그래머스
2023.04.16
class Solution { public int solution(int chicken) { int answer = -1; int coopon = (chicken / 10) + (chicken % 10); answer = chicken / 10; chicken = coopon; while (chicken >= 10) { coopon = (chicken / 10) + (chicken % 10); answer += chicken / 10; chicken = coopon; } return answer; } }
Algorithm/프로그래머스
2023.04.16
class Solution { public String solution(String bin1, String bin2) { return Integer.toBinaryString((Integer.parseInt(bin1, 2)) + Integer.parseInt(bin2, 2)); } } n -> 10진수 String a = "11"; // Binary to Decimal System.out.println(Integer.parseInt(a, 2)); //3 // Octal to Decimal System.out.println(Integer.parseInt(a, 8)); //9 // Hexadecimal to Decimal System.out.println(Integer.parseInt(a, 16)); //1..