This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import java.util.*; | |
| class Solution { | |
| public int[] solution(int[] array, int[][] commands) { | |
| int[] answer = new int[commands.length]; //commands[i] ๋งํผ์ ๋ฐฐ์ด ์์ฑ | |
| int[] temp = {}; //temp ๋ฐฐ์ด ์์ฑ | |
| for(int i=0; i<commands.length; i++){ | |
| temp = Arrays.copyOfRange(array, commands[i][0]-1, commands[i][1]); //์๋ฅด๊ธฐ | |
| Arrays.sort(temp); //์ ๋ ฌ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import java.util.*; | |
| class Solution { | |
| public int[] solution(int[] progresses, int[] speeds) { | |
| Queue<Integer> queue = new LinkedList<>(); | |
| for(int i=0; i<progresses.length; i++){ | |
| queue.add((int) (Math.ceil((100.0 - progresses[i]) / speeds[i]))); | |
| } | |
| List<Integer> answer = new ArrayList<>(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Solution { | |
| public int[] solution(int[] progresses, int[] speeds) { | |
| int[] temp = new int[100]; //์์ ์ ๊ฐ์๋ 100๊ฐ ์ดํ์ด๋ฏ๋ก 100์ผ๋ก ์ ์ธ | |
| int day = 0; //temp์ ์ ์ฉํ ๋ฐฐํฌ์ผ ์ | |
| //๊ฐ ํญ๋ชฉ๋ง๋ค 100๊น์ง ๊ฒ์ฌํด์ผํ๋ฏ๋ก for๋ฌธ์์ while๋ฌธ์ด ๋ค์ด๊ฐ๋ค. | |
| for(int i=0; i<progresses.length; i++){ | |
| while(progresses[i] + (speeds[i] * day) < 100){ | |
| day++; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import java.util.*; | |
| class Solution { | |
| public int solution(int[] citations) { | |
| int answer = 0; | |
| Arrays.sort(citations); //๋ด๋ฆผ์ฐจ์ ์ ๋ ฌ | |
| for(int i=0; i<citations.length; i++){ | |
| int h=citations.length-i; | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Solution { | |
| public int[] solution(int[] arr) { | |
| //๋ฐฐ์ด ๊ธธ์ด๊ฐ 1์ธ ๊ฒฝ์ฐ | |
| if(arr.length == 1){ | |
| int[] answer = {-1}; | |
| return answer; | |
| } | |
| //๋ฐฐ์ด๊ธธ์ด๊ฐ 1๋ณด๋ค ํด ๋ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class Solution { | |
| public int solution(int n) { | |
| int answer = 0; | |
| while(n > 0){ | |
| answer += n%10; | |
| n/=10; | |
| } | |
| return answer; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class Solution { | |
| public int solution(int n) { | |
| int answer = 0; | |
| String s = Integer.toString(n); //int n์ String์ผ๋ก ๋ณํ | |
| for(int i=0; i<s.length(); i++){ | |
| answer += Integer.parseInt(s.substring(i, i+1)); | |
| } | |
| return answer; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Solution { | |
| public String solution(String s) { | |
| String answer = ""; | |
| String[] str = s.split(""); | |
| int idx = 0; //์ธ๋ฑ์ค | |
| for(int i=0; i<str.length; i++){ | |
| if(str[i].equals(" ")){ //๋์ด์ฐ๊ธฐ ์๋ค๋ฉด | |
| idx = 0; //์ธ๋ฑ์ค 0 ์ด๊ธฐํ | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Solution { | |
| public String solution(String s, int n) { | |
| String answer = ""; | |
| for(int i=0; i<s.length(); i++){ | |
| char ch = s.charAt(i); | |
| if(Character.isLowerCase(ch)){ //์๋ฌธ์ | |
| ch = (char)((ch-'a'+n)%26 + 'a'); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Solution { | |
| public String solution(String s) { | |
| String answer = ""; | |
| if(s.length() % 2 == 0){ //์ง์ | |
| answer += s.charAt(s.length()/2-1); | |
| answer += s.charAt(s.length()/2) | |
| } | |
| else { //ํ์ | |
| answer += s.charAt(s.length()/2); |
NewerOlder