[level 1] ํ์ค๋ ์ - 12947 ๋ฌธ์ ๋งํฌ ์ฑ๋ฅ ์์ฝ ๋ฉ๋ชจ๋ฆฌ: 75.6 MB, ์๊ฐ: 0.11 ms ๊ตฌ๋ถ ์ฝ๋ฉํ
์คํธ ์ฐ์ต > ์ฐ์ต๋ฌธ์ ์ฑ์ ๊ฒฐ๊ณผ Empty ๋ฌธ์ ์ค๋ช
์์ ์ ์ x๊ฐ ํ์ค๋ ์์ด๋ ค๋ฉด x์ ์๋ฆฟ์์ ํฉ์ผ๋ก x๊ฐ ๋๋์ด์ ธ์ผ ํฉ๋๋ค. ์๋ฅผ ๋ค์ด 18์ ์๋ฆฟ์ ํฉ์ 1+8=9์ด๊ณ , 18์ 9๋ก ๋๋์ด ๋จ์ด์ง๋ฏ๋ก 18์ ํ์ค๋ ์์
๋๋ค. ์์ฐ์ x๋ฅผ ์
๋ ฅ๋ฐ์ x๊ฐ ํ์ค๋ ์์ธ์ง ์๋์ง ๊ฒ์ฌํ๋ ํจ์, solution์ ์์ฑํด์ฃผ์ธ์. ์ ํ ์กฐ๊ฑด x๋ 1 ์ด์, 10000 ์ดํ์ธ ์ ์์
๋๋ค. ์
์ถ๋ ฅ ์ x return 10 true 12 true 11 false 13 false ์
์ถ๋ ฅ ์ ์ค๋ช
์
์ถ๋ ฅ ์ #1 10์ ๋ชจ๋ ์๋ฆฟ์์ ํฉ์ 1์
๋๋ค. 10์ 1๋ก ๋๋์ด ๋จ์ด์ง๋ฏ๋ก 10์ ํ์ค๋ ..
ALGORITHM ๐ค/Programmers
ํ๋ก๊ทธ๋๋จธ์คhttps://school.programmers.co.kr/learn/courses/30/lessons/160586 import java.util.*; class Solution { public int[] solution(String[] keymap, String[] targets) { int[] answer = new int[targets.length]; Map pressCount = new HashMap(); // key: ๋ฌธ์, value: ์ต์ ์
๋ ฅ ํ์ for (String key : keymap) { // ๊ฐ ๋ฌธ์๋ฅผ ์
๋ ฅํ๊ธฐ ์ํด ํค๋ฅผ ๋๋ฅด๋ ์ต์ ํ์๋ฅผ ๋งต์ ์ ์ฅ for (int i = 0; i < key.length(); i++) { char ch = key.charAt(i); if (!p..
https://school.programmers.co.kr/learn/courses/30/lessons/42586 import java.util.*; class Solution { public int[] solution(int[] progresses, int[] speeds) { int[] day = new int[progresses.length]; Queue queue = new LinkedList(); List answer = new ArrayList(); for (int i = 0; i < progresses.length; i++) { int temp = progresses[i]; while (temp < 100) { temp += speeds[i]; day[i] += 1; } queue.add(d..
https://school.programmers.co.kr/learn/courses/30/lessons/42889 import java.util.*; class Solution { public int[] solution(int N, int[] stages) { Map map = new HashMap(); for (int i = 1; i = i) { all++; if (j == i) { fail++; } } } double per = (double) fail / all; // ์คํจ์จ if(fail == 0 && all == 0) { // ๋ชจ๋ ์ฌ๋๋ค์ด ์๋์กฐ์ฐจ ๋ชปํ ์คํ
์ด์ง๊ฐ ์์ ๋๋ 0์ผ๋ก ์ฒ๋ฆฌ (0 / 0 = NaN ๋ฐฉ์ง) per = 0; } map.put(i, per); // key: ์คํ
์ด์ง, v..
https://school.programmers.co.kr/learn/courses/30/lessons/42840 import java.util.*; class Solution { public int[] solution(int[] answers) { int[] supoza1 = {1, 2, 3, 4, 5}; int[] supoza2 = {2, 1, 2, 3, 2, 4, 2, 5}; int[] supoza3 = {3, 3, 1, 1, 2, 2, 4, 4, 5, 5}; int[] score = new int[3]; int a = 1; int temp = 0; for (int k : answers) { // ์ํฌ์1 ์ ์ ๊ตฌํ๊ธฐ if (supoza1[temp] == k) { score[0] += a; } te..
https://school.programmers.co.kr/learn/courses/30/lessons/176963 class Solution { public int[] solution(String[] name, int[] yearning, String[][] photo) { int[] answer = new int[photo.length]; for (int i = 0; i < photo.length; i++) { for (int j = 0; j < photo[i].length; j++) { for (int k = 0; k < name.length; k++) { if (name[k].equals(photo[i][j])) { answer[i] += yearning[k]; } } } } return answ..