PROGRAMMERS
-
PROGRAMMERES Level 1 연습문제 2016년 (JAVA 자바)PROGRAMMERS/연습문제 2022. 8. 16. 11:01
class Solution { public String solution(int a, int b) { String cal[] = {"FRI", "SAT", "SUN", "MON", "TUE", "WED", "THU"}; int CalDay[] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; int MonSum=0; //1월~a월 전달까지의 일수 구하기 for(int i=0; i
-
PROGRAMMERES Level 1 월간 코드 챌린지 시즌1 3진법 뒤집기PROGRAMMERS/챌린지 2022. 8. 6. 23:46
import java.util.*; class Solution { public int solution(int n) { int answer = 0; ArrayList arr = new ArrayList(); // 앞뒤반전된 3진법을 arr에 담기 while(n!=0) { arr.add(n%3); n /= 3; } for(int i=0; i 10진법 Integer.toBinaryString(number) // 10진법 -> 2진법 Integer.toOctalString(number) // 10진법 -> 8진법 Integer.toHexString(number) // 10진법 ->16진법
-
PROGRAMMERES Level 1 탐욕법(Greedy) 체육복 JAVAPROGRAMMERS/탐욕법(Greedy) 2022. 7. 21. 17:46
import java.util.*; class Solution { public static int solution(int n, int[] lost, int[] reserve) { int count=0; // 최댓값을 구하는 것이기 때문에 정렬시켜서 앞에서부터 앞번호부터 진행해야한다 // 예를들어 lost{4,2} reserve{3,5} 일 경우 정렬을 안시켜주면 4와 3이 짝이되어 2는 // 체육복을 못빌리지만 정렬을 시켜서 lost{2,4} reserve{3,5} 가 되면 2와 4 둘다 가능 Arrays.sort(lost); Arrays.sort(reserve); for(int i=0; i
-
PROGRAMMERES Level 1 완전탐색 모의고사 JAVAPROGRAMMERS/완전탐색 2022. 7. 21. 17:46
import java.util.*; class Solution { public int[] solution(int[] answers) { int[] supo1 = {1,2,3,4,5}; int[] supo2 = {2,1,2,3,2,4,2,5}; int[] supo3 = {3,3,1,1,2,2,4,4,5,5}; int count1=0; int count2=0; int count3=0; //supo1 for(int i=0; i