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; } }
ALGORITHM ๐ค/Programmers
ํ๋ก๊ทธ๋๋จธ์ค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; } }