자바
-
[자료구조] 해시(hash) #javaDataStructures 2021. 10. 1. 22:37
해시(Hash) 해시 자료구조 설명 해시 자료구조 JAVA 구현 해시 (hash) linkedList 에서 원하는 요소를 찾기 위해선 처음부터 끝까지 모든 요소를 탐색해야 합니다. n개의 요소가 있다면 O(n)의 시간복잡도가 걸리게 됩니다. 이것은 매우 비효율적입니다. 여러 상황에서 빠르게 데이터를 추가하거나 제거하도록 하고 싶었습니다. 그리고 무언가 찾아야 할때 빠르게 찾을 수 있어야 했습니다. 해시는 이러한 단점을 해결 할 수 있습니다. Hash는 Key, 그리고 연관된 Value를 가지고 있습니다. 모든 요 소를 살펴본 후 동일한 노드를 찾는 LinkedList와 달리 Hash는 Key가 주어지면 빠르게 Value를 찾을 수 있습니다. Hash는 Key와 Value를 저장하기 위해 연상배열(Asso..
-
[프로그래머스] 복서 정렬하기 #JAVAAlgorithm Solving/Programmers 2021. 9. 7. 15:05
[프로그래머스] 복서 정렬하기 #JAVA 코드 public class Solution { public static void main(String[] args) throws IOException{ solution(new int[]{50,82,75,120}, new String[]{"NLWL","WNLL","LWNW","WWLN"}); solution(new int[]{145,92,86}, new String[]{"NLW","WNL","LWN"}); solution(new int[]{60,70,60}, new String[]{"NNN","NNN","NNN"}); } public static int[] solution(int[] weights, String[] head2head) { int[] answer =..
-
[JAVA] 자바 가비지 컬렉션 , Java Garbage Collection #GCJAVA 2021. 7. 6. 23:35
자바 가비지 컬렉션 , Java Garbage Collection 안녕하세요? 장장스입니다. 자바의 GC에 대해 정리해보겠습니다. GC (Garbage Collection) 자바 어플리케이션은 JVM에 의해 구동이 됩니다. GC(Garbage Collection)는 JVM의 주요 기능으로 할당한 메모리 영역 중 사용하지 않는 영역을 탐지하여 해제하는 작업을 합니다. 자바의 GC(Garbage Collection)는 아주 단순한 규칙을 갖고 있습니다. Heap 영역의 오브젝트 중 stack 에서 도달 불가능한 (Unreachable) 오브젝트들은 가비지 컬렉션의 대상이 된다. 자바의 메모리 영역, heap public class Main { public static void main(String[] arg..
-
[백준] 11047 동전0 #JAVAAlgorithm Solving/BAEKJOON 2021. 2. 28. 01:30
[백준] 11047 동전0 #JAVA 코드 import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; public class Main { public static void main(String[] args) throws IOException{ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(br.readLine()); int n = Integer.parseInt(st.nextToken..
-
[백준] 12852 1로 만들기 2#JAVAAlgorithm Solving/BAEKJOON 2021. 2. 27. 18:33
[백준] 12852 1로 만들기 2#JAVA 코드 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)); StringBuilder sb = new StringBuilder(); int n = Integer.parseInt(br.readLine()); int[] d = new int[..
-
[백준] 1149 RGB거리 #JAVAAlgorithm Solving/BAEKJOON 2021. 2. 27. 00:33
[백준] 1149 RGB거리 #JAVA 코드 import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; 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+1][3]; //arr[i][j] // i번째 집에..
-
[백준] 2579 계단 오르기 #JAVAAlgorithm Solving/BAEKJOON 2021. 2. 26. 23:38
[백준] 2579 계단 오르기 #JAVA 코드 import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; 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+1]; int[][] d = new int[n+1][3]; //거리 정보를 담을 배열 for (int i = 1;..
-
[백준] 1463 1로 만들기 #JAVA #DPAlgorithm Solving/BAEKJOON 2021. 2. 25. 23:50
[백준] 1463 1로 만들기 #JAVA #DP 코드 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[] d = new int[n+1]; Arrays.fill(d, Integer.MAX_VALUE..
-
[백준] 1463 1로만들기 #JAVA #BFSAlgorithm Solving/BAEKJOON 2021. 2. 25. 21:48
[백준] 1463 1로만들기 #JAVA #BFS 코드 import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Arrays; import java.util.LinkedList; import java.util.Queue; public class Main { static int cnt; public static void main(String[] args) throws IOException{ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int n = Integer.parseInt(br...
-
[백준] 2146 다리만들기 #JAVAAlgorithm Solving/BAEKJOON 2021. 2. 25. 01:01
[백준] 2146 다리만들기 #JAVA 코드 import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.LinkedList; import java.util.Queue; import java.util.StringTokenizer; public class Main { static int n; static int[][] map; static int[][] island; static int[][] dist; static int[] dx = {0,1,0,-1}; static int[] dy = {1,0,-1,0}; static Queue queue; public static v..