[99ํด๋Ÿฝ ์ฝ”ํ…Œ ์Šคํ„ฐ๋””] 15์ผ์ฐจ
ยท
๐Ÿ“– Study
์˜ค๋Š˜์˜ ํ•™์Šต ํ‚ค์›Œ๋“œ์Šคํƒ๋ฌธ์ œ - ๋ฏธ๋“ค๋Ÿฌ๊ฐ™์€ ์ˆซ์ž๋Š” ์‹ซ์–ดํ’€์ด 1import java.util.*;public class Solution { public int[] solution(int []arr) { ArrayList list = new ArrayList(); list.add(arr[0]); for(int i = 1; i ํ’€์ด 2import java.util.*;public class Solution { public int[] solution(int []arr) { Stack stack = new Stack(); for(int num : arr) { if(stack.size() == 0..
[99ํด๋Ÿฝ ์ฝ”ํ…Œ ์Šคํ„ฐ๋””] 10์ผ์ฐจ
ยท
๐Ÿ“– Study
์˜ค๋Š˜์˜ ํ•™์Šต ํ‚ค์›Œ๋“œBFS๋ฌธ์ œ - ๋ฏธ๋“ค๋ŸฌํŠน์ • ๊ฑฐ๋ฆฌ์˜ ๋„์‹œ ์ฐพ๊ธฐํ’€์ดimport java.util.*;class Main { static int n; // ๋„์‹œ์˜ ์ˆ˜ static int m; // ๋„๋กœ์˜ ๊ฐœ์ˆ˜ static int k; // ๊ฑฐ๋ฆฌ ์ •๋ณด static int x; // ์ถœ๋ฐœ ๋„์‹œ ๋ฒˆํ˜ธ static int[] visited; static ArrayList> graph; static void bfs(int start) { Queue q = new LinkedList(); q.offer(start); visited[start] = 0; while(!q.isEmpty()) { int x = q.poll(); for(int i = 0; i (); fo..
[99ํด๋Ÿฝ ์ฝ”ํ…Œ ์Šคํ„ฐ๋””] 9์ผ์ฐจ
ยท
๐Ÿ“– Study
์˜ค๋Š˜์˜ ํ•™์Šต ํ‚ค์›Œ๋“œBFS๋ฌธ์ œ - ๋ฏธ๋“ค๋Ÿฌ๋‚˜์ดํŠธ์˜ ์ด๋™ํ’€์ดimport java.util.*;class Main { static int testCase; static int l; static int[][] board; static boolean[][] visited; static int[] dx = {1, 2, 2, 1, -1, -2, -2, -1}; static int[] dy = {2, 1, -1, -2, -2, -1, 1, 2}; static void bfs(int startX, int startY, int targetX, int targetY) { Queue q = new LinkedList(); q.offer(new int[]{startX, startY}); visited..
[99ํด๋Ÿฝ ์ฝ”ํ…Œ ์Šคํ„ฐ๋””] 8์ผ์ฐจ
ยท
๐Ÿ“– Study
์˜ค๋Š˜์˜ ํ•™์Šต ํ‚ค์›Œ๋“œBFS๋ฌธ์ œ - ๋ฏธ๋“ค๋Ÿฌ์ดŒ์ˆ˜ ๊ณ„์‚ฐํ’€์ดimport java.util.*;class Main { static int n; static int a, b; static int m; static ArrayList> list; static int[] visited; static void bfs(int start) { Queue q = new LinkedList(); q.offer(start); visited[start] = 0; while(!q.isEmpty()) { int x = q.poll(); for(int i = 0; i (); visited = new int[n + 1]; Arrays.fill(visited, -1); for(..
[99ํด๋Ÿฝ ์ฝ”ํ…Œ ์Šคํ„ฐ๋””] 5์ผ์ฐจ
ยท
๐Ÿ“– Study
์˜ค๋Š˜์˜ ํ•™์Šต ํ‚ค์›Œ๋“œBFS๋ฌธ์ œ - ๋น„๊ธฐ๋„ˆ๋ชจ์Šค ๋ถ€ํ˜ธํ’€์ดimport java.util.*;class Main { public static Map map = new HashMap(); public static void main(String[] args) { map.put(".-", "A"); map.put("-...", "B"); map.put("-.-.", "C"); map.put("-..", "D"); map.put(".", "E"); map.put("..-.", "F"); map.put("--.", "G"); map.put("....", "H"); map.put("..", "I"); map.put(".---", "J"); map.put("-.-..
[99ํด๋Ÿฝ ์ฝ”ํ…Œ ์Šคํ„ฐ๋””] 4์ผ์ฐจ
ยท
๐Ÿ“– Study
์˜ค๋Š˜์˜ ํ•™์Šต ํ‚ค์›Œ๋“œDFS๋ฌธ์ œ - ๋น„๊ธฐ๋„ˆ์ˆซ์ž ๋ฌธ์ž์—ด๊ณผ ์˜๋‹จ์–ดํ’€์ดclass Solution { public int solution(String s) { String[] words = new String[] {"zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine"}; for(int i = 0; i ๋ฌธ์ œ - ๋ฏธ๋“ค๋Ÿฌ์•Œ๊ณ ๋ฆฌ์ฆ˜ ์ˆ˜์—… - ๊นŠ์ด ์šฐ์„  ํƒ์ƒ‰ 1ํ’€์ดimport java.util.*;class Main { public static int[] answer; public static int n; // ์ •์ ์˜ ์ˆ˜ public static int m; // ๊ฐ„์„ ์˜ ์ˆ˜ public static..
[99ํด๋Ÿฝ ์ฝ”ํ…Œ ์Šคํ„ฐ๋””] 3์ผ์ฐจ
ยท
๐Ÿ“– Study
์˜ค๋Š˜์˜ ํ•™์Šต ํ‚ค์›Œ๋“œ๊ตฌํ˜„์ด๋ถ„ํƒ์ƒ‰๋ฌธ์ œ - ๋น„๊ธฐ๋„ˆํฌ๊ธฐ๊ฐ€ ์ž‘์€ ๋ถ€๋ถ„ ๋ฌธ์ž์—ดํ’€์ดclass Solution { public int solution(String s) { int answer = 0; String[] strArr = s.split(""); int idx = 0; while(idx ์ฃผ์–ด์ง„ ๋ฌธ์ œ๋ฅผ ๋”ฐ๋ผ ๊ทธ๋Œ€๋กœ ๊ตฌํ˜„ํ–ˆ์Šต๋‹ˆ๋‹ค.๋ฌธ์ œ - ๋ฏธ๋“ค๋Ÿฌ๊ฒฝ๋กœ ์ฐพ๊ธฐํ’€์ดimport java.util.*;class Solution { public long solution(int n, int[] times) { long answer = 0; Arrays.sort(times); long left = 0; ..
[99ํด๋Ÿฝ ์ฝ”ํ…Œ ์Šคํ„ฐ๋””] 2์ผ์ฐจ
ยท
๐Ÿ“– Study
์˜ค๋Š˜์˜ ํ•™์Šต ํ‚ค์›Œ๋“œ๊ตฌํ˜„์ด๋ถ„ํƒ์ƒ‰๋ฌธ์ œ - ๋น„๊ธฐ๋„ˆํฌ๊ธฐ๊ฐ€ ์ž‘์€ ๋ถ€๋ถ„ ๋ฌธ์ž์—ดํ’€์ดclass Solution { public int solution(String t, String p) { int answer = 0; int pLen = p.length(); int maxIdx = t.length() - pLen + 1; for (int i = 0; i = Long.parseLong(tmp)) answer++; } return answer; }}์ฒ˜์Œ ๋ฌธ์ œ๋ฅผ ํ’€์—ˆ์„ ๋•Œ, 3๊ฐœ์˜ ํ…Œ์ŠคํŠธ ์ผ€์ด์Šค๋Š” ํ†ต๊ณผํ–ˆ์ง€๋งŒ, ์ •๋‹ต์„ ์ œ์ถœํ•  ๋•Œ, ๋Ÿฐํƒ€์ž„ ์˜ค๋ฅ˜๊ฐ€ ๋ฐœ์ƒํ–ˆ์Šต๋‹ˆ๋‹ค.๊ทธ ์ด์œ ๋Š” ๋ฌธ์ œ์˜ ์กฐ๊ฑด์— p์˜ ๊ธธ์ด๋Š” ์ตœ๋Œ€ 18์ž๋ฆฌ๋ผ๋Š” ์กฐ๊ฑด์ด ์žˆ์—ˆ์Šต๋‹ˆ๋‹ค.์ˆ˜์˜ ํฌ๊ธฐ๊ฐ€..
[99ํด๋Ÿฝ ์ฝ”ํ…Œ ์Šคํ„ฐ๋””] 1์ผ์ฐจ
ยท
๐Ÿ“– Study
์˜ค๋Š˜์˜ ํ•™์Šต ํ‚ค์›Œ๋“œ๊ตฌํ˜„์ด๋ถ„ ํƒ์ƒ‰๋ฌธ์ œ - ๋น„๊ธฐ๋„ˆ๋ฌธ์ž์—ด ๋‚ด p์™€ y์˜ ๊ฐœ์ˆ˜ํ’€์ดclass Solution { boolean solution(String s) { char[] chArr = s.toCharArray(); for(int i = 0; i ๋ฌธ์ œ - ๋ฏธ๋“ค๋Ÿฌํ’€์ด๋ถ€๋™์†Œ์ˆ˜์  ์˜ค์ฐจ์ž๋ฐ”์—์„œ ์‹ค์ˆ˜๋ฅผ ํ‘œํ˜„ํ•  ๋•Œ ๋ถ€๋™์†Œ์ˆ˜์  ๋ฐฉ์‹์„ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค. ๋ถ€๋™์†Œ์ˆ˜์  ๋ฐฉ์‹์„ ์‚ฌ์šฉํ•˜๋ฉด ๋ณด๋‹ค ์ •๋ฐ€ํ•˜๊ฒŒ ์†Œ์ˆ˜๋ฅผ ํ‘œํ˜„ํ•  ์ˆ˜ ์žˆ์ง€๋งŒ, ์™„์ „ํžˆ ์ •ํ™•ํ•˜๊ฒŒ ํ‘œํ˜„ํ•˜๋Š” ๊ฒƒ์€ ์•„๋‹™๋‹ˆ๋‹ค. ๋ฏธ์„ธํ•˜๊ฒŒ ์˜ค์ฐจ๊ฐ€ ๋ฐœ์ƒํ•ฉ๋‹ˆ๋‹ค.์ด๋Ÿฌํ•œ ๋ฌธ์ œ๋ฅผ ํ•ด๊ฒฐํ•˜๋ ค๋ฉด ์ •์ˆ˜ํ˜• ํƒ€์ž… int, long์œผ๋กœ ์น˜ํ™˜ํ•˜๊ฑฐ๋‚˜ BigDecimal ํด๋ž˜์Šค๋ฅผ ์ด์šฉํ•˜๋ฉด ๋ฉ๋‹ˆ๋‹ค.Scanner, BufferedReader, StringTokenizer์ฐธ๊ณ โ˜• JAVA ๊ธฐ๋ณธ ์ž๋ฃŒํ˜•..