ALGORITHM ๐Ÿค–

์•Œ๊ณ ๋ฆฌ์ฆ˜ ์—ฐ์Šต / ์ฝ”๋”ฉํ…Œ์ŠคํŠธ ์ค€๋น„
https://school.programmers.co.kr/learn/courses/30/lessons/120812 class Solution { public int solution(int[] array) { int answer = 0; // ์ตœ๋นˆ๊ฐ’ int max = Integer.MIN_VALUE; // ์ตœ๋Œ€๊ฐ’ ์ €์žฅ int[] index = new int[1001]; // ์ธ๋ฑ์Šค ์นด์šดํŒ… for (int j : array) { index[j]++; // ๊ฐœ์ˆ˜ ์„ธ์„œ ์ธ๋ฑ์Šค ๋ฐฐ์—ด์— ์นด์šดํŒ… ๊ฒฐ๊ณผ ๋ฐ˜์˜ } for(int i = 0; i < index.length; i++){ if(max < index[i]){ max = index[i]; // ๊ฐ€์žฅ ๋งŽ์ด ์นด์šดํŒ… ๋œ ์ˆ˜๊ฐ€ ์ตœ๋นˆ๊ฐ’ answer = i; } } int..
https://school.programmers.co.kr/learn/courses/30/lessons/120906 class Solution { public int solution(int n) { int answer = 0; String str = n + ""; // ๋ฌธ์ž์—ด๋กœ ๋ณ€ํ™˜ for(int i = 0; i < str.length(); i++){ char c = str.charAt(i); // ๋ฌธ์ž ํ•˜๋‚˜์”ฉ ์ž˜๋ผ์„œ answer += Character.getNumericValue(c); // ์ •์ˆ˜๋กœ ๋ณ€ํ™˜ํ•ด์ค€ ๋‹ค์Œ ๋”ํ•˜๊ธฐ } return answer; } }
https://school.programmers.co.kr/learn/courses/30/lessons/120818 class Solution { public int solution(int price) { if(100000
https://school.programmers.co.kr/learn/courses/30/lessons/120898 class Solution { public int solution(String message) { int answer = message.length(); // ๋ฉ”์„ธ์ง€ ๊ธ€์ž ์ˆ˜ return answer*2; // ํ•œ ๊ธ€์ž ๋‹น 2cm ์ด๋ฏ€๋กœ ๊ธ€์ž์ˆ˜์— 2๋ฅผ ๊ณฑํ•ด์คŒ } }
https://school.programmers.co.kr/learn/courses/30/lessons/120889 import java.util.Arrays; class Solution { public int solution(int[] sides) { Arrays.sort(sides); // ์˜ค๋ฆ„์ฐจ์ˆœ ์ •๋ ฌ if(sides[0]+sides[1] > sides[2]){ // ๊ฐ€์žฅ ๊ธด ๋ณ€์˜ ๊ธธ์ด๊ฐ€ ๋‹ค๋ฅธ ๋‘ ๋ณ€์˜ ๊ธธ์ด์˜ ํ•ฉ๋ณด๋‹ค ์ž‘์„ ๋•Œ return 1; // 1 ์ถœ๋ ฅ (์‚ผ๊ฐํ˜• ๋งŒ๋“ค ์ˆ˜ ์žˆ์Œ) } else{ // ๊ทธ๋ ‡์ง€ ์•Š์œผ๋ฉด return 2; // 2 ์ถœ๋ ฅ (์‚ผ๊ฐํ˜• ๋งŒ๋“ค ์ˆ˜ ์—†์Œ) } } }
https://school.programmers.co.kr/learn/courses/30/lessons/120819 class Solution { public int[] solution(int money) { int[] answer = new int[2]; answer[0] = money / 5500; answer[1] = money % 5500; return answer; } }
https://school.programmers.co.kr/learn/courses/30/lessons/120847 import java.util.Arrays; class Solution { public int solution(int[] numbers) { Arrays.sort(numbers); int answer = numbers[numbers.length-2] * numbers[numbers.length-1]; return answer; } }
daxx0ne
'ALGORITHM ๐Ÿค–' ์นดํ…Œ๊ณ ๋ฆฌ์˜ ๊ธ€ ๋ชฉ๋ก (13 Page)