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.substring(s.length()/2-1, s.length()/2+1); | |
| }else { //νμ | |
| answer = s.substring(s.length()/2, s.length()/2+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
| import java.util.ArrayList; | |
| public class Solution { | |
| public int[] solution(int []arr) { | |
| int[] answer = {}; | |
| ArrayList<Integer> arrList = new ArrayList<Integer>(); | |
| int num = -1; //μμκ° 0~9κΉμ§ μ΄λ―λ‘ μν₯ μλ°λ μ무 μ«μ. | |
| for(int i=0; i<arr.length; i++){ | |
| if(arr[i] != num){ |
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 long solution(int price, int money, int count) { | |
| long answer; | |
| long sum = 0; | |
| long result; | |
| //μκΈ ν© κ³μ° | |
| for(int i=1; i<count+1; i++){ | |
| result = i * price; | |
| sum += result; |
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 n) { | |
| int answer = 0; | |
| for (int i=2; i<n; i++){ | |
| if(n%i == 1){ | |
| answer = i; | |
| break; | |
| } | |
| } |
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[] d, int budget) { | |
| int answer = 0; | |
| int result = 0; //μμ° κ²°κ³Ό | |
| Arrays.sort(d); //μ λ ¬ | |
| //μμ μλΆν° λνλ κ²μ΄ κ°μ₯ μ΅λμ κ°μ λΈλ€. | |
| for(int i=0; i<d.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
| import java.util.*; | |
| class Solution { | |
| public String solution(String[] participant, String[] completion) { | |
| String answer = ""; | |
| //participant : λ§λΌν€μ μ°Έμ¬ν μ μλ€μ μ΄λ¦ λ°°μ΄ | |
| //completion : μμ£Όν μ μλ€μ μ΄λ¦μ΄ λ΄κΈ΄ λ°°μ΄ | |
| Arrays.sort(participant); |
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[][] sizes) { | |
| int max_width = 0; | |
| int max_height = 0; | |
| int wallet_size; | |
| for(int i=0; i<sizes.length; i++){ | |
| int 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
| class Solution { | |
| public String solution(int n) { | |
| String answer = ""; | |
| String su = "μ"; | |
| String bac = "λ°"; | |
| for(int i=0; i<n; i++){ | |
| //μ§μ | |
| if(i % 2 == 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
| import java.util.Scanner; | |
| public class Main { | |
| public static void main(String[] args) { | |
| Scanner sc = new Scanner(System.in); | |
| int[] arr = new int[26]; //μλ¬Έμ κ°―μ 26κ° | |
| String word = sc.next(); | |
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 n, int[] lost, int[] reserve) { | |
| int answer = 0; //체μ‘μμ λ€μ μ μλ νμμ μ΅λκ° | |
| int count = 0; //λΉλ¦° νμ μ | |
| //μ¬λ² μ·μ κ°μ§κ³ μλ νμμ΄ λλ λΉνλ©΄ λΉλ €μ€ μ μλλ‘ λ§λ λ€. | |
| for(int i=0; i<lost.length; i++){ | |
| for(int j=0; j<reserve.length; j++){ | |
| if(lost[i]==reserve[j]){ //λλ λΉν νμ == μ¬λ²μ· κ°μ Έμ¨ νμ | |
| lost[i] = reserve[j] = -1; //-1λ‘ μ΄κΈ°ν |