๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
๋ฐ˜์‘ํ˜•

๊ฐœ๋ฐœ/์•Œ๊ณ ๋ฆฌ์ฆ˜12

[ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค/JAVA] ์ฒด์œก๋ณต ๐Ÿ‘‡ ๋ฌธ์ œ URL ๐Ÿ‘‡ ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค ์ฝ”๋“œ ์ค‘์‹ฌ์˜ ๊ฐœ๋ฐœ์ž ์ฑ„์šฉ. ์Šคํƒ ๊ธฐ๋ฐ˜์˜ ํฌ์ง€์…˜ ๋งค์นญ. ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค์˜ ๊ฐœ๋ฐœ์ž ๋งž์ถคํ˜• ํ”„๋กœํ•„์„ ๋“ฑ๋กํ•˜๊ณ , ๋‚˜์™€ ๊ธฐ์ˆ  ๊ถํ•ฉ์ด ์ž˜ ๋งž๋Š” ๊ธฐ์—…๋“ค์„ ๋งค์นญ ๋ฐ›์œผ์„ธ์š”. programmers.co.kr ํƒ์š•๋ฒ• ๋ฌธ์ œ! ํƒ์š•๋ฒ•์ด๋ž€ ๋งค ์„ ํƒ์—์„œ ์ตœ์ ์˜ ๊ฒฐ๊ณผ๋ฅผ ๋งŒ๋“ค์–ด๋‚ด๋Š” ๊ฒƒ. import java.util.Arrays; class Solution { public int solution(int n, int[] lost, int[] reserve) { int answer = n; int[] student = new int[n]; //์ผ๋‹จ ๋ชจ๋‘ ์ฒด์œก๋ณต์„ ๊ฐ€์ ธ์˜จ ๊ฒƒ์œผ๋กœ ์„ธํŒ… (1,1,1,1,1) Arrays.fill(student, 1); Arrays.sort(lost); Arrays.sort(rese.. 2022. 7. 25.
[ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค/JAVA] ํ‚คํŒจ๋“œ ๋ˆ„๋ฅด๊ธฐ ๐Ÿ‘‡ ๋ฌธ์ œ URL ๐Ÿ‘‡ ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค ์ฝ”๋“œ ์ค‘์‹ฌ์˜ ๊ฐœ๋ฐœ์ž ์ฑ„์šฉ. ์Šคํƒ ๊ธฐ๋ฐ˜์˜ ํฌ์ง€์…˜ ๋งค์นญ. ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค์˜ ๊ฐœ๋ฐœ์ž ๋งž์ถคํ˜• ํ”„๋กœํ•„์„ ๋“ฑ๋กํ•˜๊ณ , ๋‚˜์™€ ๊ธฐ์ˆ  ๊ถํ•ฉ์ด ์ž˜ ๋งž๋Š” ๊ธฐ์—…๋“ค์„ ๋งค์นญ ๋ฐ›์œผ์„ธ์š”. programmers.co.kr 2,5,8,0์ผ ๊ฒฝ์šฐ ์˜ค๋ฅธ์†, ์™ผ์†์ด ์œ„์น˜ํ•œ ํ‚คํŒจ๋“œ์—์„œ์˜ ๊ฑฐ๋ฆฌ๋ฅผ ๊ตฌํ•ด์•ผ ํ–ˆ๊ธฐ ๋•Œ๋ฌธ์— ์ขŒํ‘œ๋ฅผ ์ด์šฉํ•˜์—ฌ ํ’€์—ˆ๋‹ค. ๊ทธ๋ฆฌ๊ณ  Stream API์— ์žˆ๋Š” anyMatch๋ฅผ ์ด์šฉํ•˜์—ฌ ์ตœ์†Œํ•œ ํ•œ ๊ฐœ์˜ ์š”์†Œ๊ฐ€ ์ฃผ์–ด์ง„ ์กฐ๊ฑด์— ๋งŒ์กฑํ•˜๋Š”์ง€๋ฅผ ์ฒดํฌํ•˜์˜€๋‹ค. import java.util.Arrays; class Solution { public String solution(int[] numbers, String hand) { String answer = ""; int[] leftHand = {1,4,7}; int[].. 2022. 7. 25.
[ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค/JAVA] ์ˆซ์ž ๋ฌธ์ž์—ด๊ณผ ์˜๋‹จ์–ด ๐Ÿ‘‡ ๋ฌธ์ œ URL ๐Ÿ‘‡ ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค ์ฝ”๋“œ ์ค‘์‹ฌ์˜ ๊ฐœ๋ฐœ์ž ์ฑ„์šฉ. ์Šคํƒ ๊ธฐ๋ฐ˜์˜ ํฌ์ง€์…˜ ๋งค์นญ. ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค์˜ ๊ฐœ๋ฐœ์ž ๋งž์ถคํ˜• ํ”„๋กœํ•„์„ ๋“ฑ๋กํ•˜๊ณ , ๋‚˜์™€ ๊ธฐ์ˆ  ๊ถํ•ฉ์ด ์ž˜ ๋งž๋Š” ๊ธฐ์—…๋“ค์„ ๋งค์นญ ๋ฐ›์œผ์„ธ์š”. programmers.co.kr ์†Œ์Šค ์ฝ”๋“œ String[] engNum = {"zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine"}; //i๋Š” 0~9 for(int i=0; i 2022. 7. 24.
[ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค/JAVA] ์‹ ๊ทœ ์•„์ด๋”” ์ถ”์ฒœ ๐Ÿ‘‡ ๋ฌธ์ œ URL ๐Ÿ‘‡ ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค ์ฝ”๋“œ ์ค‘์‹ฌ์˜ ๊ฐœ๋ฐœ์ž ์ฑ„์šฉ. ์Šคํƒ ๊ธฐ๋ฐ˜์˜ ํฌ์ง€์…˜ ๋งค์นญ. ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค์˜ ๊ฐœ๋ฐœ์ž ๋งž์ถคํ˜• ํ”„๋กœํ•„์„ ๋“ฑ๋กํ•˜๊ณ , ๋‚˜์™€ ๊ธฐ์ˆ  ๊ถํ•ฉ์ด ์ž˜ ๋งž๋Š” ๊ธฐ์—…๋“ค์„ ๋งค์นญ ๋ฐ›์œผ์„ธ์š”. programmers.co.kr class Solution { public String solution(String new_id) { String answer = ""; //1๋‹จ๊ณ„ new_id = new_id.toLowerCase(); System.out.println("1๋‹จ๊ณ„ :"+new_id); //2๋‹จ๊ณ„ StringBuffer sb = new StringBuffer(); for(int i=0; i= 16){ new_id = new_id.substring(0, 15); new_id = new_id.replaceAll(.. 2022. 7. 24.
[ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค/JAVA] ๋กœ๋˜์˜ ์ตœ๊ณ  ์ˆœ์œ„์™€ ์ตœ์ € ์ˆœ์œ„ ๐Ÿ‘‡ ๋ฌธ์ œ URL ๐Ÿ‘‡ ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค ์ฝ”๋“œ ์ค‘์‹ฌ์˜ ๊ฐœ๋ฐœ์ž ์ฑ„์šฉ. ์Šคํƒ ๊ธฐ๋ฐ˜์˜ ํฌ์ง€์…˜ ๋งค์นญ. ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค์˜ ๊ฐœ๋ฐœ์ž ๋งž์ถคํ˜• ํ”„๋กœํ•„์„ ๋“ฑ๋กํ•˜๊ณ , ๋‚˜์™€ ๊ธฐ์ˆ  ๊ถํ•ฉ์ด ์ž˜ ๋งž๋Š” ๊ธฐ์—…๋“ค์„ ๋งค์นญ ๋ฐ›์œผ์„ธ์š”. programmers.co.kr class Solution { public int[] solution(int[] lottos, int[] win_nums) { int[] answer = new int[2]; int cnt = 0; int zeroCnt = 0; for(int num : lottos){ if(num ==0){ zeroCnt ++; } for(int win_num : win_nums){ if(num == win_num){ cnt++; } } } int minCnt = cnt; int maxCnt = cnt+z.. 2022. 7. 24.
[ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค/JAVA] ์‹ ๊ณ  ๊ฒฐ๊ณผ ๋ฐ›๊ธฐ ๐Ÿ‘‡ ๋ฌธ์ œ URL ๐Ÿ‘‡ ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค ์ฝ”๋“œ ์ค‘์‹ฌ์˜ ๊ฐœ๋ฐœ์ž ์ฑ„์šฉ. ์Šคํƒ ๊ธฐ๋ฐ˜์˜ ํฌ์ง€์…˜ ๋งค์นญ. ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค์˜ ๊ฐœ๋ฐœ์ž ๋งž์ถคํ˜• ํ”„๋กœํ•„์„ ๋“ฑ๋กํ•˜๊ณ , ๋‚˜์™€ ๊ธฐ์ˆ  ๊ถํ•ฉ์ด ์ž˜ ๋งž๋Š” ๊ธฐ์—…๋“ค์„ ๋งค์นญ ๋ฐ›์œผ์„ธ์š”. programmers.co.kr import java.util.HashMap; import java.util.HashSet; import java.util.Map; public static int[] solution(String[] id_list, String[] report, int k) { int[] answer = new int[id_list.length]; // HashMap : Key-value, hashSet: set ์ค‘ ์„ฑ๋Šฅ์ด ๊ฐ€์žฅ ์ข‹์Œ // key : ์‹ ๊ณ ๋œ ID, value : ์‹ ๊ณ ํ•œ ID set Map .. 2022. 7. 24.
[ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค/JAVA] ๊ฐ€์žฅ ํฐ ์ˆ˜ - ์ •๋ ฌ ์ด ๋ฌธ์ œ๋„ ์‰ฝ๊ฒŒ ์ž˜ ํ’€๋ ธ๋‹ค๊ณ  ์ƒ๊ฐํ–ˆ๊ณ , ๋ฌธ์ œ์˜ ์˜ˆ์ œ๊ฐ€ ๋‚ด๊ฐ€ ๋Œ€์ž…ํ•œ ์ˆซ์ž๋กœ๋Š” ๊ฒฐ๊ณผ๊ฐ€ ์ž˜ ๋‚˜์™”๋‹ค. ํ•˜์ง€๋งŒ ํ…Œ์ŠคํŠธ 33.3 ์ ์„ ๋ฐ›์•˜๋‹ค..ใ…Žใ…Ž ์ด ์ •๋„๋ฉด ์˜ˆ์ œ๊ฐ€ ์šด ์ข‹๊ฒŒ ๋งž์€ ์ˆ˜์ค€.. public String solution(int[] numbers) { String answer = ""; Integer[]numbers2 = Arrays.stream(numbers).boxed().toArray(Integer[]::new); Arrays.sort(numbers2, new Comparator() { @Override public int compare(Integer o1, Integer o2) { if(o1.toString().charAt(0) == o2.toString().charAt(0)) { if(o1.toS.. 2022. 2. 20.
[ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค/JAVA] K๋ฒˆ์งธ์ˆ˜ - ์ •๋ ฌ ๋ ˆ๋ฒจ 1์ด๋ผ ๋น ๋ฅด๊ณ  ์‰ฝ๊ฒŒ ํ’€์—ˆ๋‹ค! public int[] solution(int[] array, int[][] commands) { int[] answer = new int[commands.length]; for(int i=0; i 2022. 2. 20.
728x90
๋ฐ˜์‘ํ˜•