일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | |||||
3 | 4 | 5 | 6 | 7 | 8 | 9 |
10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 20 | 21 | 22 | 23 |
24 | 25 | 26 | 27 | 28 | 29 | 30 |
31 |
- java 1509
- 백준 2252 줄세우기
- java 백준 1509
- kotiln const
- java 팩토리얼 개수
- rabbitmq 싱글톤
- kotiln functional interface
- 백준 1504 java
- nodejs rabbitmq
- spring mongodb switch
- Spring ipfs
- mongodb lookup
- kotiln const val
- ipfs singletone
- ipfs bean
- 안정해시
- 익명 객체 @transactional
- spring mongoTemplate
- javav 1676
- Java Call By Refernce
- 전략 패턴이란
- 자바 1676
- 백준 특정한 최단 경로
- java 파티
- java 1238
- spring mongoTemplate switch
- spring mongodb
- 백준 연결요소 자바
- 자바 백준 팩토리얼 개수
- go
- Today
- Total
목록코테 (79)
공부 흔적남기기
import java.util.ArrayList; import java.util.Arrays; class Solution { public int solution(int n, int[] lost, int[] reserve) { //도둑이 여벌은 안훔쳐가고 원래 있던 체육복만 훔쳐가는 참 웃긴 문제다 int answer = 0; // 이 문제를 풀때 상식적으로 생각한다면 순차정렬을 해야하므로 정렬 Arrays.sort(lost); Arrays.sort(reserve); // arrayList를 좋아해서 ArrayList로 바꿈 ArrayList lostList = new ArrayList(); for (int i : lost) { lostList.add(i); } ArrayList reserveList = ..
import java.util.ArrayList; import java.util.Collections; class Solution { public int[] solution(int N, int[] stages) { //전체 스테이지가 N개 //현재 멈춰있는 스테이지 번호가 담긴 배열 stages //확률이 똑같은 경우 처리와 쓸데없는 곳에서의 실수 때문에 1시간 넘게 걸려서 푼문제이다;; int[] stop_people = new int[N+2]; // 1 2 3 4 5 6 //스테이지를 전부 클리어한 사람이 있을 수 있고 //0번째 스테이지는 없기 때문에를 처리해주기 위해 N+2 배열을 만듦 //각 스테이지 마다 멈춰 있는 사람 수 더해주기 for(int i =0; i
class Solution { public int solution(int n) { //보통 소수찾는 알고리즘에서는 에라토스네스체의 방식이 사용됨 소수 찾을 땐 이게 짱임 int answer = eratosneSosu(n); return answer; } //에라토스네스체 구현 방법 //2부터 n의 제곱근까지 돌면서 자신의 을 제외하고 자신의 배수들 다 지우기 public int eratosneSosu(int n){ int arr[] = new int[n+1]; //일단 1부터 정해진 곳까지 전부 수를 채운 배열을 만듬 for(int i=1; i
class Solution { public int solution(int n) { int answer = 0; // n을 i로 나눠서 나머지가 1이 되는 수 중 가장 작은 값 //가장 작은 수를 찾아야 하므로 위에서 부터 찾음 //생각해보니 아래서부터 찾은다음에 break; 를 걸면 되는 거였네;; for(int i =n-1; i>1; i--){ if(n%i==1){; answer = i; } } return answer; } } 출처: https://programmers.co.kr/learn/courses/30/lessons/87389 코딩테스트 연습 - 나머지가 1이 되는 수 찾기 자연수 n이 매개변수로 주어집니다. n을 x로 나눈 나머지가 1이 되도록 하는 가장 작은 자연수 x를 return 하도록..
import java.util.ArrayList; import java.util.Collections; class Solution { public int[] solution(int[] array, int[][] commands) { //각 command 마다 하나의 결과 값이 나오므로 commands의 길이의 배열 만듦 int[] answer = new int[commands.length]; ArrayList arrayList = new ArrayList(); // for(int i =0; i
class Solution { public int[] solution(int n, int m) { if( n > m){ int temp = n; n = m; m = temp; } System.out.println(mindiv(n,m)); System.out.println(maxmul(n,m)); int[] answer = {mindiv(n,m), maxmul(n,m)}; return answer; } //유클리드 호제법을 사용하면 코드를 짧게 구성할 수 있지만 (재귀 방식으로) //그냥 직관적으로 짜봄 //n
import java.util.ArrayList; import java.util.Collections; class Solution { public int solution(int[] d, int budget) { int answer = 0; ArrayList arrayList = new ArrayList(); //습관 2차원배열이 아닌 이상 배열은 ArrayList로 바꿔 푸는게 편해서 바꿈 for (int i : d) { arrayList.add(i); } // 정렬 Collections.sort(arrayList); int count = 0; while(count != d.length){ //예산에서 부서별 신청금액을 작은 것 부터 차례대로 뺌 // 작은 것 부터 뺴야 살 수 있는 부서가 최대가 될 수..
class Solution { public int solution(int n) { return yaksu(n); } // 1 2 3 4 6 12 public int yaksu(int num){ int count = 0; //num의 약수를 1부터 num의 양의 제곱근 까지 확인함 for(int i =1; i
class Solution { public int solution(int left, int right) { int sum = 0; for(int i =left; i
class Solution { public String solution(String new_id) { String answer = ""; //이문제는 그냥 주어진 로직따라 풀면 풀리는 문제 //따로 설명 X //1단계 new_id = new_id.toLowerCase(); //2단계 String[] strings = {"~", "!", "@", "#", "\\$", "%", "\\^", "&", "\\*", "\\(", "\\)", "=", "\\+", "\\[", "\\{", "]", "}", ":", "\\?", ",", "", "/"}; for (int i = 0; i < strings.length; i++) { new_id = new_id.replaceAll(strings[i], ""); } //..