목록자바 (14)
study record
자바의 10진수를 2진수, 8진수, 16진수로 만들기 String octalString = Integer.toOctalString(i); //8진수 String hexString = Integer.toHexString(i); String binaryString = Integer.toBinaryString(i); //2진수 10진수로 만들기 int binaryToOctal = Integer.parseInt(octalString, 8); int binaryToHex = Integer.parseInt(hexString, 16); int binaryToDecimal = Integer.parseInt(binaryString, 2);
이해를 도운 블로그들 - 결과값을 추가해준 블로그 limkydev.tistory.com/178 [JAVA] 조합,중복조합,순열,중복순열 소스 JAVA 조합,중복조합,순열,중복순열 소스 이번 시간은 JAVA로 조합, 중복조합, 순열, 중복순열을 알아보겠습니다. 기본적으로 4개 모두 재귀호출을 통해 구현할 수 있습니다. 먼저 순열은 순서있게 limkydev.tistory.com - 코드가 간결한 블로그 https://gaybee.tistory.com/29 [알고리즘/자바] 조합, 순열, 중복조합, 중복순열 알고리즘 문제를 접하다 보면 조합, 순열, 중복 조합, 중복순열을 필요로 하는 문제가 많다. 브루트 포스를 이용할 때 이러한 로직들을 많이 사용한다. 그래서 로직을 만들어놓고 사용하면 그때 gaybee.t..
더 맵게 PriorityQueue 를 사용하는 문제 heap은 정렬하지 않아도 peek()이나 poll()하면 가장 작은 값이 나온다. 힙은 우선순위 큐를 위해 만들어진 자료구조로, 부모노드 키 값이 자식 노드 키 값보다 항상 크거나 작다. import java.util.PriorityQueue; public class Spicer { public int solution(int[] scoville, int K) { int answer = 0; PriorityQueue heap = new PriorityQueue(); for (int i = 0; i K) { if(heap.siz..
완주하지못한 선수 HashMap을 이용한 문제 풀이 hash.put(key, value), hash.get(key)를 이용한 문제풀이를 진행했다. import java.util.HashMap; public class Hash { public static void main(String[] args) { String[] participant = {"marina", "josipa", "nikola", "vinko", "filipa"}; String[] completion = {"josipa", "filipa", "marina", "nikola"}; System.out.println(solution(participant, completion)); } public static String solution(Stri..