2024/04/09 3

99클럽 코테 스터디 9일차 TIL - 백준 1697번 (숨바꼭질)

bfs로 count를 구하는 문제 bfs: queue를 이용하여 count 구하기 쉬움 dfs: 재귀 함수로 구현되기에 count 구하기 쉽지 않음 예시 : 수빈이 N - 5, 동생 K - 17 0초 1초 2초 3초 4초에 17 도달 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()); int N = Integer.pa..

자바 기본 자료구조 선언 정리

자바를 오랜만에 써서 기본 자료구조를 선언하는 방법이 헷갈리는 본인을 위한 정리 map Map map = new HashMap(); SortedMap sortedMap = new TreeMap(); queue Queue q = new LinkedList(); Queue 변수명 = new LinkedList(); //다른 자료형 넣기 가능 // 기본형: 우선순위가 낮은 숫자가 먼저 나옴 (작은 숫자) PriorityQueue pQ = new PriorityQueue(); // 우선순위가 높은 숫자가 먼저 나옴 (큰 숫자) PriorityQueue pQ = new PriorityQueue(Collections.reverseOrder()); stack Stack stackInt = new Stack(); de..

algorithm/정리 2024.04.09