ALGORITHM ๐Ÿค–/Programmers

ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค
https://school.programmers.co.kr/learn/courses/30/lessons/68935 class Solution { public int solution(int n) { int answer = 0; String temp = Integer.toString(n, 3); // 10์ง„๋ฒ• -> 3์ง„๋ฒ• String reverse = ""; for (int i = temp.length() - 1; i >= 0; i--) { // 3์ง„๋ฒ• ์ƒ์—์„œ ์•ž๋’ค ๋ฐ˜์ „ reverse = reverse + temp.charAt(i); } answer = Integer.parseInt(reverse, 3); // ๋ฐ˜์ „ํ•œ 3์ง„๋ฒ• -> 10์ง„๋ฒ• return answer; } }
https://school.programmers.co.kr/learn/courses/30/lessons/120899 class Solution { public int[] solution(int[] array) { int[] answer = new int[2]; for(int i = 0; i < array.length; i++){ if(answer[0] < array[i]){ answer[0] = array[i]; answer[1] = i; } } return answer; } }
https://school.programmers.co.kr/learn/courses/30/lessons/12926 class Solution { public String solution(String s, int n) { StringBuilder answer = new StringBuilder(); char[] arr = s.toCharArray(); for (int i = 0; i 'z') { answer.append((char) (arr..
https://school.programmers.co.kr/learn/courses/30/lessons/12930 class Solution { public String solution(String s) { String answer = ""; String text = ""; int space = 0; for(int i = 0; i < s.length(); i++){ text = s.substring(i, i+1); // ํ•œ ๊ธ€์ž์”ฉ ์ž๋ฆ„ if(text.equals(" ")){ // ๊ณต๋ฐฑ ๋ฌธ์ž ์žˆ์„ ๋•Œ answer += text; space = 0; // ๋ฆฌ์…‹ (๊ณต๋ฐฑ ๊ธฐ์ค€ ๋‹จ์–ด ๋ณ„๋กœ ์ง/ํ™€ ํŒ๋‹จ) } else{ if(space % 2 == 0){ // ์ง์ˆ˜ ์ธ๋ฑ์Šค์ผ ๋•Œ answer += text.toUppe..
https://school.programmers.co.kr/learn/courses/30/lessons/12906 import java.util.*; public class Solution { public int[] solution(int []arr) { ArrayList arrayList = new ArrayList(); arrayList.add(arr[0]); for(int i = 1; i < arr.length; i++){ if(arr[i] != arr[i - 1]) // ๋ฐฐ์—ด arr์˜ ์›์†Œ๋ฅผ ๋น„๊ตํ•˜์—ฌ ์ค‘๋ณต์ด ์—†์„๋•Œ๋งŒ, arrayList.add(arr[i]); // ํ•ด๋‹น ์›์†Œ๋ฅผ ๋ฆฌ์ŠคํŠธ์— ๋‹ด๊ธฐ } int[] answer = new int[arrayList.size()]; // ๋ฆฌ์ŠคํŠธ์— ๋‹ด๊ธด ์›์†Œ ์ˆ˜๋งŒ..
https://school.programmers.co.kr/learn/courses/30/lessons/12941 import java.util.Arrays; class Solution { public int solution(int []A, int []B) { int answer = 0; int size = B.length; Arrays.sort(A); Arrays.sort(B); for(int i = 0; i < A.length; i++){ answer += A[i] * B[size - (1 + i)]; } return answer; } }
https://school.programmers.co.kr/learn/courses/30/lessons/12945 class Solution { public int solution(int n) { long num1 = 0; long num2 = 1; for(int i = 0; i = 1234567) { num1 = num2 % 1234567; num2 = sum % 1234567; } else { num1 = num2; num2 = sum; } } int answer = (int) num1; return answer; } }
daxx0ne
'ALGORITHM ๐Ÿค–/Programmers' ์นดํ…Œ๊ณ ๋ฆฌ์˜ ๊ธ€ ๋ชฉ๋ก (2 Page)