ALGORITHM ๐Ÿค–/Programmers

ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค
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; } }
https://school.programmers.co.kr/learn/courses/30/lessons/120815 class Solution { public int solution(int n) { int max = 0; for(int i=1; i
https://school.programmers.co.kr/learn/courses/30/lessons/120813 class Solution { public int[] solution(int n) { int[] answer = new int[(n / 2) + (n % 2)]; // ๋ฐฐ์—ด์˜ ํฌ๊ธฐ ์ง€์ • int a = 1; for(int i = 0; i < answer.length; i++){ // ๋ฐฐ์—ด ํฌ๊ธฐ๋งŒํผ ๋ฐ˜๋ณต answer[i] = a; // ํ™€์ˆ˜๋งŒ ๋‹ด๊ธฐ a += 2; } return answer; } }
https://school.programmers.co.kr/learn/courses/30/lessons/120811 import java.util.Arrays; // ํด๋ž˜์Šค ์ •์˜ class Solution { public int solution(int[] array) { Arrays.sort(array); // ์ •๋ ฌ ๋ฉ”์†Œ๋“œ ์‚ฌ์šฉํ•˜์—ฌ ์˜ค๋ฆ„์ฐจ์ˆœ ์ •๋ ฌ int answer = array[array.length/2]; // ์ค‘์•™๊ฐ’ ๊ตฌํ•˜๊ธฐ return answer; } }
https://school.programmers.co.kr/learn/courses/30/lessons/120808?language=java class Solution { public int[] solution(int numer1, int denom1, int numer2, int denom2) { int numer = (numer1 * denom2) + (numer2 * denom1); // ํ†ต๋ถ„ํ–ˆ์„ ๋•Œ ๋ถ„์ž int denom = denom1 * denom2; // ํ†ต๋ถ„ํ–ˆ์„ ๋•Œ ๋ถ„๋ชจ for(int i = numer - 1; i > 1; i--){ // ๊ธฐ์•ฝ๋ถ„์ˆ˜ ์ธ์ง€ ์ฒดํฌ if(numer % i == 0 && denom % i == 0){ // ๊ธฐ์•ฝ๋ถ„์ˆ˜๊ฐ€ ์•„๋‹ˆ๋ฉด ์•ฝ๋ถ„ํ•ด์ฃผ๊ธฐ numer /= i; denom..
https://school.programmers.co.kr/learn/courses/30/lessons/120833 class Solution { public int[] solution(int[] numbers, int num1, int num2) { int[] answer = new int [num2 - num1 + 1]; // ๋ฐฐ์—ด์˜ ํฌ๊ธฐ๋ฅผ ์„ค์ • int a = 0; for(int i = num1; i
https://school.programmers.co.kr/learn/courses/30/lessons/120825 class Solution { public String solution(String my_string, int n) { String answer = ""; for(int i=0; i < my_string.length(); i++){ // ๋ฌธ์ž์—ด์˜ ๊ธธ์ด๋งŒํผ ์•„๋ž˜ for ๋ฌธ์„ ๋ฐ˜๋ณต for(int j=0; j
daxx0ne
'ALGORITHM ๐Ÿค–/Programmers' ์นดํ…Œ๊ณ ๋ฆฌ์˜ ๊ธ€ ๋ชฉ๋ก (7 Page)