📌Set 인터페이스를 구현하는 클래스 - HashSet, TreeSet, LinkedHashSet 등 📌Set 특징 -List와 다르게 객체를 중복해서 저장할 수 없다. ex) 20 10 10 30 40 20 10 30 40만 저장됨. 중복해서 저장할 수 없는 대신에 순서가 보장되지 않는다. 📌Set 공통 메소드 boolean add(E e) - 객체 저장 후 성공이면 true, 실패면 false를 리턴 boolean contains(Object o) - 객체가 있는지 여부 리턴 boolean isEmpty() - 컬렉션이 비어있는지 확인 boolean remove(Object o) - 인자로 받은 요소를 삭제한다. int size() - 요소의 개수를 리턴 Object[] toArray() -set을 ..
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 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 package Binary_Search; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Arrays; import java.util.StringTokenizer; public class Main { static StringBuilder sb = new..
오답 노트 & 새로 알게 된 점 듣보잡 문제는 이분 탐색 문제이지만, 다루는 자료형이 String형이다. 이 문제를 풀면서 문자열에 관한 메소드를 많이 알아가게 됐다. 1. Arrays.sort는 배열을 오름차순으로 정렬해주는 메소드 2. Collections.sort는 List형을 오름차순으로 정렬해주는 메소드이다. compareTo 메소드를 볼 수 있다. 처음에는 구글링을 잘못하여 compareTo 메소드를 사용하면서 반환하는 숫자가 0 , -1, 1밖에 없다고 생각한 것이다. 그러나 compareTo 메소드는 A.compareTo(B) 일 때, A가 B보다 앞선다면 음수가 나온다. 물론 정확한 어떤 숫자가 반환되는지는 알 수 있다. 아스키코드를 이용하여, 포함되어 있는 문자에서 빼주면 되는데 이 부..
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 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Arrays; import java.util.StringTokenizer; public class Main { static int [] arr1; //있는지 확인하는 배열 static in..
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 import java.util.*; import java.io.*; 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()); long s = Long.parseLong(st.nextToken()); long sum = 0; long count = 0; /..

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 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 package BFS; import java.io.*; import java.util.*; public class Main { static int M,N; static int ad[][]; static boolean visit[][]; static int count = 0; s..
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 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 package BFS; import java.util.*; public class Main { static int row,col,myeon; static int ad[][][]; static boolean visit[][][]; static Queue q ..
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 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 import java.util.*; import java.io.*; public class Main { static int nV, nE; static ArrayList ad[]; public static void main(String args[]) throws IOException { BufferedReader br = new BufferedRe..
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 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 import java.io.*; import java.util.*; public class Main { static int n,m; static boolean visit[]; static ArrayList ad[]; static int limit[]; public static void main(String[] args) throws IOException { Buffered..
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 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 import java.io.*; import java.util.*; public class Main { static int n, m; static int ad[][]; static boolean visit[][]; static int count[][]; public static void main(String[] args) throws IOException { BufferedReader b..
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 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 import java.io.*; import java.util.*; public class Main { static int n,m; static int ad[][]; static boolean visit[][]; public static void main(String[] args) throws IOException{ BufferedReader b..
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 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 import java.io.*; import java.util.*; public class Main { static int width, height, garbage; static int ad[][]; static boolean visit[][]; public static void main(String[] args) throws IOEx..