<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
    <channel>
        <title>yewon_s.log</title>
        <link>https://velog.io/</link>
        <description></description>
        <lastBuildDate>Mon, 14 Nov 2022 15:05:21 GMT</lastBuildDate>
        <docs>https://validator.w3.org/feed/docs/rss2.html</docs>
        <generator>https://github.com/jpmonette/feed</generator>
        <image>
            <title>yewon_s.log</title>
            <url>https://images.velog.io/images/yewon_s/profile/8d3b6660-4004-4e07-b2da-ca4c810dda3e/social.png</url>
            <link>https://velog.io/</link>
        </image>
        <copyright>Copyright (C) 2019. yewon_s.log. All rights reserved.</copyright>
        <atom:link href="https://v2.velog.io/rss/yewon_s" rel="self" type="application/rss+xml"/>
        <item>
            <title><![CDATA[[프로그래머스] 삼총사 - Java]]></title>
            <link>https://velog.io/@yewon_s/%ED%94%84%EB%A1%9C%EA%B7%B8%EB%9E%98%EB%A8%B8%EC%8A%A4-%EC%82%BC%EC%B4%9D%EC%82%AC-Java</link>
            <guid>https://velog.io/@yewon_s/%ED%94%84%EB%A1%9C%EA%B7%B8%EB%9E%98%EB%A8%B8%EC%8A%A4-%EC%82%BC%EC%B4%9D%EC%82%AC-Java</guid>
            <pubDate>Mon, 14 Nov 2022 15:05:21 GMT</pubDate>
            <description><![CDATA[<h3 id="문제-설명"><strong>문제 설명</strong></h3>
<p>한국중학교에 다니는 학생들은 각자 정수 번호를 갖고 있습니다. 이 학교 학생 3명의 정수 번호를 더했을 때 0이 되면 3명의 학생은 삼총사라고 합니다. 예를 들어, 5명의 학생이 있고, 각각의 정수 번호가 순서대로 -2, 3, 0, 2, -5일 때, 첫 번째, 세 번째, 네 번째 학생의 정수 번호를 더하면 0이므로 세 학생은 삼총사입니다. 또한, 두 번째, 네 번째, 다섯 번째 학생의 정수 번호를 더해도 0이므로 세 학생도 삼총사입니다. 따라서 이 경우 한국중학교에서는 두 가지 방법으로 삼총사를 만들 수 있습니다.</p>
<p>한국중학교 학생들의 번호를 나타내는 정수 배열 number가 매개변수로 주어질 때, 학생들 중 삼총사를 만들 수 있는 방법의 수를 return 하도록 solution 함수를 완성하세요.</p>
<ul>
<li>제한사항<ul>
<li>3 ≤ number의 길이 ≤ 13</li>
<li>-1,000 ≤ number의 각 원소 ≤ 1,000</li>
<li>서로 다른 학생의 정수 번호가 같을 수 있습니다.</li>
</ul>
</li>
</ul>
<h3 id="풀이"><strong>풀이</strong></h3>
<pre><code>class Solution {
    static int numArr[];
    static int N;
    static int temp[] = new int[3];
    static int count = 0;

    public int solution(int[] number) {
        int answer = 0;
        N = number.length;
        numArr = number;        
        DFS(0,0);
        return count;
    }
    private static void DFS(int idx, int depth){
        if(depth == 3){
            int sum = 0;
            for(int i = 0 ; i &lt; 3; i++){
                sum += temp[i];   
            }
            if(sum == 0){
                count++;
            }
            return;
        }

        for(int i = idx; i &lt; N; i++){
            temp[depth] = numArr[i];
            DFS(i+1, depth + 1);
        }
    }
}</code></pre><h3 id="다른-사람의-풀이"><strong>다른 사람의 풀이</strong></h3>
<pre><code></code></pre>]]></description>
        </item>
        <item>
            <title><![CDATA[[프로그래머스] K번째 수 - Java]]></title>
            <link>https://velog.io/@yewon_s/%ED%94%84%EB%A1%9C%EA%B7%B8%EB%9E%98%EB%A8%B8%EC%8A%A4-K%EB%B2%88%EC%A7%B8-%EC%88%98-Java</link>
            <guid>https://velog.io/@yewon_s/%ED%94%84%EB%A1%9C%EA%B7%B8%EB%9E%98%EB%A8%B8%EC%8A%A4-K%EB%B2%88%EC%A7%B8-%EC%88%98-Java</guid>
            <pubDate>Mon, 14 Nov 2022 14:18:15 GMT</pubDate>
            <description><![CDATA[<h3 id="문제-설명"><strong>문제 설명</strong></h3>
<p>배열 array의 i번째 숫자부터 j번째 숫자까지 자르고 정렬했을 때, k번째에 있는 수를 구하려 합니다.</p>
<p>예를 들어 array가 [1, 5, 2, 6, 3, 7, 4], i = 2, j = 5, k = 3이라면</p>
<p>array의 2번째부터 5번째까지 자르면 [5, 2, 6, 3]입니다.
1에서 나온 배열을 정렬하면 [2, 3, 5, 6]입니다.
2에서 나온 배열의 3번째 숫자는 5입니다.
배열 array, [i, j, k]를 원소로 가진 2차원 배열 commands가 매개변수로 주어질 때, commands의 모든 원소에 대해 앞서 설명한 연산을 적용했을 때 나온 결과를 배열에 담아 return 하도록 solution 함수를 작성해주세요.</p>
<ul>
<li>제한사항<ul>
<li>array의 길이는 1 이상 100 이하입니다.</li>
<li>array의 각 원소는 1 이상 100 이하입니다.</li>
<li>commands의 길이는 1 이상 50 이하입니다.</li>
<li>commands의 각 원소는 길이가 3입니다.</li>
</ul>
</li>
</ul>
<h3 id="풀이"><strong>풀이</strong></h3>
<pre><code>import java.util.Arrays;

class Solution {
    public int[] solution(int[] array, int[][] commands) {
        int[] answer = new int[commands.length];
        int index = 0;

        for(int i = 0 ; i &lt; commands.length; i++){
            int start = commands[i][0];
            int end   = commands[i][1];
            int k     = commands[i][2];

            int temp[] = new int[end-start+1];

            int x = 0;

            for(int j = start-1; j &lt; end; j++){
                temp[x++] = array[j];
            }    
                Arrays.sort(temp);                
                answer[index++] = temp[k-1];                       
        }

        return answer;
    }
}</code></pre><h3 id="다른-사람의-풀이"><strong>다른 사람의 풀이</strong></h3>
<pre><code>import java.util.Arrays;
class Solution {
    public int[] solution(int[] array, int[][] commands) {
        int[] answer = new int[commands.length];

        for(int i=0; i&lt;commands.length; i++){
            int[] temp = Arrays.copyOfRange(array, commands[i][0]-1, commands[i][1]);
            Arrays.sort(temp);
            answer[i] = temp[commands[i][2]-1];
        }

        return answer;
    }
}</code></pre>]]></description>
        </item>
        <item>
            <title><![CDATA[[프로그래머스] 같은 숫자는 싫어 - Java]]></title>
            <link>https://velog.io/@yewon_s/%ED%94%84%EB%A1%9C%EA%B7%B8%EB%9E%98%EB%A8%B8%EC%8A%A4-%EA%B0%99%EC%9D%80-%EC%88%AB%EC%9E%90%EB%8A%94-%EC%8B%AB%EC%96%B4-Java</link>
            <guid>https://velog.io/@yewon_s/%ED%94%84%EB%A1%9C%EA%B7%B8%EB%9E%98%EB%A8%B8%EC%8A%A4-%EA%B0%99%EC%9D%80-%EC%88%AB%EC%9E%90%EB%8A%94-%EC%8B%AB%EC%96%B4-Java</guid>
            <pubDate>Tue, 08 Nov 2022 13:58:26 GMT</pubDate>
            <description><![CDATA[<h3 id="문제-설명"><strong>문제 설명</strong></h3>
<p>배열 arr가 주어집니다. 배열 arr의 각 원소는 숫자 0부터 9까지로 이루어져 있습니다. 이때, 배열 arr에서 연속적으로 나타나는 숫자는 하나만 남기고 전부 제거하려고 합니다. 단, 제거된 후 남은 수들을 반환할 때는 배열 arr의 원소들의 순서를 유지해야 합니다. 예를 들면,</p>
<p>arr = [1, 1, 3, 3, 0, 1, 1] 이면 [1, 3, 0, 1] 을 return 합니다.
arr = [4, 4, 4, 3, 3] 이면 [4, 3] 을 return 합니다.
배열 arr에서 연속적으로 나타나는 숫자는 제거하고 남은 수들을 return 하는 solution 함수를 완성해 주세요.</p>
<ul>
<li>제한사항<ul>
<li>배열 arr의 크기 : 1,000,000 이하의 자연수</li>
<li>배열 arr의 원소의 크기 : 0보다 크거나 같고 9보다 작거나 같은 정수</li>
</ul>
</li>
</ul>
<h3 id="풀이"><strong>풀이</strong></h3>
<pre><code>import java.util.*;

public class Solution {
    public int[] solution(int []arr) {
        int temp = 10;

        ArrayList&lt;Integer&gt; list = new ArrayList&lt;Integer&gt;();

        for(int i = 0; i &lt; arr.length; i++){
            if(temp != arr[i])
               list.add(arr[i]);
            temp = arr[i];                
        }

        int[]answer = new int[list.size()];

        for(int i = 0; i &lt; answer.length; i++){
            answer[i] = list.get(i);
        }

        return answer;
    }
}</code></pre><h3 id="다른-사람의-풀이"><strong>다른 사람의 풀이</strong></h3>
<pre><code>import java.util.*;

public class Solution {
    public int[] solution(int []arr) {
        ArrayList&lt;Integer&gt; tempList = new ArrayList&lt;Integer&gt;();
        int preNum = 10;
        for(int num : arr) {
            if(preNum != num)
                tempList.add(num);
            preNum = num;
        }       
        int[] answer = new int[tempList.size()];
        for(int i=0; i&lt;answer.length; i++) {
            answer[i] = tempList.get(i).intValue();
        }
        return answer;
    }
}</code></pre>]]></description>
        </item>
        <item>
            <title><![CDATA[[프로그래머스] 모의고사 - Java]]></title>
            <link>https://velog.io/@yewon_s/%ED%94%84%EB%A1%9C%EA%B7%B8%EB%9E%98%EB%A8%B8%EC%8A%A4-%EB%AA%A8%EC%9D%98%EA%B3%A0%EC%82%AC-Java</link>
            <guid>https://velog.io/@yewon_s/%ED%94%84%EB%A1%9C%EA%B7%B8%EB%9E%98%EB%A8%B8%EC%8A%A4-%EB%AA%A8%EC%9D%98%EA%B3%A0%EC%82%AC-Java</guid>
            <pubDate>Tue, 08 Nov 2022 13:20:25 GMT</pubDate>
            <description><![CDATA[<h3 id="문제-설명"><strong>문제 설명</strong></h3>
<p>수포자는 수학을 포기한 사람의 준말입니다. 수포자 삼인방은 모의고사에 수학 문제를 전부 찍으려 합니다. 수포자는 1번 문제부터 마지막 문제까지 다음과 같이 찍습니다.</p>
<p>1번 수포자가 찍는 방식: 1, 2, 3, 4, 5, 1, 2, 3, 4, 5, ...
2번 수포자가 찍는 방식: 2, 1, 2, 3, 2, 4, 2, 5, 2, 1, 2, 3, 2, 4, 2, 5, ...
3번 수포자가 찍는 방식: 3, 3, 1, 1, 2, 2, 4, 4, 5, 5, 3, 3, 1, 1, 2, 2, 4, 4, 5, 5, ...</p>
<p>1번 문제부터 마지막 문제까지의 정답이 순서대로 들은 배열 answers가 주어졌을 때, 가장 많은 문제를 맞힌 사람이 누구인지 배열에 담아 return 하도록 solution 함수를 작성해주세요.</p>
<ul>
<li>제한 조건<ul>
<li>시험은 최대 10,000 문제로 구성되어있습니다.</li>
<li>문제의 정답은 1, 2, 3, 4, 5중 하나입니다.</li>
<li>가장 높은 점수를 받은 사람이 여럿일 경우, return하는 값을 오름차순 정렬해주세요.</li>
</ul>
</li>
</ul>
<h3 id="풀이"><strong>풀이</strong></h3>
<pre><code>import java.util.ArrayList;

class Solution {
    public int[] solution(int[] answers) {
        int [] a = {1,2,3,4,5};
        int [] b = {2,1,2,3,2,4,2,5};
        int [] c = {3,3,1,1,2,2,4,4,5,5};

        int [] score = new int[3];

        for(int i = 0 ; i &lt; answers.length; i++){
            if(answers[i] == a[i%5])
                score[0]++;
            if(answers[i] == b[i%8])
                score[1]++;
            if(answers[i] == c[i%10])
                score[2]++;            
        }

        int max = 0;

        ArrayList&lt;Integer&gt; list = new ArrayList&lt;Integer&gt;();

        for(int i = 0; i &lt; score.length; i++){
            if (max &lt; score[i])
                max = score[i];  
        }

        for(int i = 0; i &lt; score.length; i++){
            if(max == score[i])
               list.add(i+1);
        }

        int [] answer = new int[list.size()];

        for(int i = 0; i &lt; answer.length; i++){
            answer[i] = list.get(i);
        }        
        return answer;
    }
}</code></pre><h3 id="다른-사람의-풀이"><strong>다른 사람의 풀이</strong></h3>
<pre><code>import java.util.*;

class Solution {
    public static int[] solution(int[] answers) {
        int[][] patterns = {
                {1, 2, 3, 4, 5},
                {2, 1, 2, 3, 2, 4, 2, 5},
                {3, 3, 1, 1, 2, 2, 4, 4, 5, 5}
        };

        int[] hit = new int[3];
        for(int i = 0; i &lt; hit.length; i++) {
            for(int j = 0; j &lt; answers.length; j++) {
                if(patterns[i][j % patterns[i].length] == answers[j]) hit[i]++;
            }
        }

        int max = Math.max(hit[0], Math.max(hit[1], hit[2]));
        List&lt;Integer&gt; list = new ArrayList&lt;&gt;();
        for(int i = 0; i &lt; hit.length; i++)
            if(max == hit[i]) list.add(i + 1);

        int[] answer = new int[list.size()];
        int cnt = 0;
        for(int num : list)
            answer[cnt++] = num;
        return answer;
    }
}</code></pre>]]></description>
        </item>
        <item>
            <title><![CDATA[[프로그래머스] 로또의 최고 순위와 최저 순위- Java]]></title>
            <link>https://velog.io/@yewon_s/%ED%94%84%EB%A1%9C%EA%B7%B8%EB%9E%98%EB%A8%B8%EC%8A%A4-%EB%A1%9C%EB%98%90%EC%9D%98-%EC%B5%9C%EA%B3%A0-%EC%88%9C%EC%9C%84%EC%99%80-%EC%B5%9C%EC%A0%80-%EC%88%9C%EC%9C%84-Java</link>
            <guid>https://velog.io/@yewon_s/%ED%94%84%EB%A1%9C%EA%B7%B8%EB%9E%98%EB%A8%B8%EC%8A%A4-%EB%A1%9C%EB%98%90%EC%9D%98-%EC%B5%9C%EA%B3%A0-%EC%88%9C%EC%9C%84%EC%99%80-%EC%B5%9C%EC%A0%80-%EC%88%9C%EC%9C%84-Java</guid>
            <pubDate>Wed, 02 Nov 2022 14:01:59 GMT</pubDate>
            <description><![CDATA[<h3 id="문제-설명"><strong>문제 설명</strong></h3>
<p>로또 6/45(이하 &#39;로또&#39;로 표기)는 1부터 45까지의 숫자 중 6개를 찍어서 맞히는 대표적인 복권입니다. 아래는 로또의 순위를 정하는 방식입니다.</p>
<p>순위    당첨 내용
1    6개 번호가 모두 일치
2    5개 번호가 일치
3    4개 번호가 일치
4    3개 번호가 일치
5    2개 번호가 일치
6(낙첨)    그 외
로또를 구매한 민우는 당첨 번호 발표일을 학수고대하고 있었습니다. 하지만, 민우의 동생이 로또에 낙서를 하여, 일부 번호를 알아볼 수 없게 되었습니다. 당첨 번호 발표 후, 민우는 자신이 구매했던 로또로 당첨이 가능했던 최고 순위와 최저 순위를 알아보고 싶어 졌습니다.
알아볼 수 없는 번호를 0으로 표기하기로 하고, 민우가 구매한 로또 번호 6개가 44, 1, 0, 0, 31 25라고 가정해보겠습니다. 당첨 번호 6개가 31, 10, 45, 1, 6, 19라면, 당첨 가능한 최고 순위와 최저 순위의 한 예는 아래와 같습니다.</p>
<p>당첨 번호    31    10    45    1    6    19    결과
최고 순위 번호    31    0→10    44    1    0→6    25    4개 번호 일치, 3등
최저 순위 번호    31    0→11    44    1    0→7    25    2개 번호 일치, 5등</p>
<ul>
<li>순서와 상관없이, 구매한 로또에 당첨 번호와 일치하는 번호가 있으면 맞힌 걸로 인정됩니다.</li>
<li>알아볼 수 없는 두 개의 번호를 각각 10, 6이라고 가정하면 3등에 당첨될 수 있습니다.<ul>
<li>3등을 만드는 다른 방법들도 존재합니다. 하지만, 2등 이상으로 만드는 것은 불가능합니다.</li>
</ul>
</li>
<li>알아볼 수 없는 두 개의 번호를 각각 11, 7이라고 가정하면 5등에 당첨될 수 있습니다.<ul>
<li>5등을 만드는 다른 방법들도 존재합니다. 하지만, 6등(낙첨)으로 만드는 것은 불가능합니다.</li>
</ul>
</li>
</ul>
<p>민우가 구매한 로또 번호를 담은 배열 lottos, 당첨 번호를 담은 배열 win_nums가 매개변수로 주어집니다. 이때, 당첨 가능한 최고 순위와 최저 순위를 차례대로 배열에 담아서 return 하도록 solution 함수를 완성해주세요.</p>
<p>제한사항</p>
<ul>
<li>lottos는 길이 6인 정수 배열입니다.</li>
<li>lottos의 모든 원소는 0 이상 45 이하인 정수입니다.<ul>
<li>0은 알아볼 수 없는 숫자를 의미합니다.</li>
<li>0을 제외한 다른 숫자들은 lottos에 2개 이상 담겨있지 않습니다.</li>
<li>lottos의 원소들은 정렬되어 있지 않을 수도 있습니다.</li>
</ul>
</li>
<li>win_nums은 길이 6인 정수 배열입니다.</li>
<li>win_nums의 모든 원소는 1 이상 45 이하인 정수입니다.<ul>
<li>win_nums에는 같은 숫자가 2개 이상 담겨있지 않습니다.</li>
<li>win_nums의 원소들은 정렬되어 있지 않을 수도 있습니다.</li>
</ul>
</li>
</ul>
<h3 id="풀이"><strong>풀이</strong></h3>
<pre><code>class Solution {
    public int[] solution(int[] lottos, int[] win_nums) {
        int[] answer = new int[2];

        int win = 0;
        int lose = 0;

        for(int i : lottos){
            if(i == 0){
                lose++;
            }
            else{
               for(int j : win_nums){
                   if(i == j){
                       win++;
                       break;
                   }
               } 
            }
        }
        answer[0] = (win+lose) &gt; 1 ? 7-(win+lose) : 6;
        answer[1] = win &gt; 1 ? 7 - win : 6;

        return answer;
    }
}</code></pre><h3 id="다른-사람의-풀이"><strong>다른 사람의 풀이</strong></h3>
<pre><code>import java.util.HashMap;
import java.util.Map;

class Solution {
    public int[] solution(int[] lottos, int[] win_nums) {
        Map&lt;Integer, Boolean&gt; map = new HashMap&lt;Integer, Boolean&gt;();
        int zeroCount = 0;

        for(int lotto : lottos) {
            if(lotto == 0) {
                zeroCount++;
                continue;
            }
            map.put(lotto, true);
        }


        int sameCount = 0;
        for(int winNum : win_nums) {
            if(map.containsKey(winNum)) sameCount++;
        }

        int maxRank = 7 - (sameCount + zeroCount);
        int minRank = 7 - sameCount;
        if(maxRank &gt; 6) maxRank = 6;
        if(minRank &gt; 6) minRank = 6;

        return new int[] {maxRank, minRank};
    }
}</code></pre>]]></description>
        </item>
        <item>
            <title><![CDATA[[프로그래머스] 비밀지도 - Java]]></title>
            <link>https://velog.io/@yewon_s/%ED%94%84%EB%A1%9C%EA%B7%B8%EB%9E%98%EB%A8%B8%EC%8A%A4-%EB%B9%84%EB%B0%80%EC%A7%80%EB%8F%84-Java</link>
            <guid>https://velog.io/@yewon_s/%ED%94%84%EB%A1%9C%EA%B7%B8%EB%9E%98%EB%A8%B8%EC%8A%A4-%EB%B9%84%EB%B0%80%EC%A7%80%EB%8F%84-Java</guid>
            <pubDate>Mon, 31 Oct 2022 14:56:43 GMT</pubDate>
            <description><![CDATA[<h3 id="문제-설명"><strong>문제 설명</strong></h3>
<p>네오는 평소 프로도가 비상금을 숨겨놓는 장소를 알려줄 비밀지도를 손에 넣었다. 그런데 이 비밀지도는 숫자로 암호화되어 있어 위치를 확인하기 위해서는 암호를 해독해야 한다. 다행히 지도 암호를 해독할 방법을 적어놓은 메모도 함께 발견했다.</p>
<ul>
<li>지도는 한 변의 길이가 n인 정사각형 배열 형태로, 각 칸은 &quot;공백&quot;(&quot; &quot;) 또는 &quot;벽&quot;(&quot;#&quot;) 두 종류로 이루어져 있다.</li>
<li>전체 지도는 두 장의 지도를 겹쳐서 얻을 수 있다. 각각 &quot;지도 1&quot;과 &quot;지도 2&quot;라고 하자. 지도 1 또는 지도 2 중 어느 하나라도 벽인 부분은 전체 지도에서도 벽이다. 지도 1과 지도 2에서 모두 공백인 부분은 전체 지도에서도 공백이다.</li>
<li>&quot;지도 1&quot;과 &quot;지도 2&quot;는 각각 정수 배열로 암호화되어 있다.</li>
<li>암호화된 배열은 지도의 각 가로줄에서 벽 부분을 1, 공백 부분을 0으로 부호화했을 때 얻어지는 이진수에 해당하는 값의 배열이다.</li>
</ul>
<h3 id="풀이"><strong>풀이</strong></h3>
<pre><code>class Solution {
    public String[] solution(int n, int[] arr1, int[] arr2) {
        String [] answer = new String[n];

        for(int i = 0; i &lt; n; i++){
            answer[i] = Integer.toBinaryString(arr1[i]|arr2[i]);
            answer[i] = answer[i].replace(&#39;0&#39;,&#39; &#39;);
            answer[i] = answer[i].replace(&#39;1&#39;,&#39;#&#39;);

            while(answer[i].length() &lt; n){
                answer[i] = &#39; &#39;+ answer[i];
            }
        }
        return answer;

    }
}</code></pre><h3 id="다른-사람의-풀이"><strong>다른 사람의 풀이</strong></h3>
<pre><code>class Solution {
    public String makeSharp(int n, int m) {
        if(n == 0) {
            if( m &gt; 0) {
                String str = &quot;&quot;;
                for(int i = 0; i &lt; m; i++) {
                    str += &quot; &quot;;
                }
                return str;
            }
            else return &quot;&quot;;
        }
        else {
            return n % 2 == 0 ? makeSharp(n/2, m-1) + &quot; &quot; : makeSharp(n/2, m-1) + &quot;#&quot;; 
        }
    }
    public String[] solution(int n, int [] arr1, int [] arr2) {
        String [] answer = new String[n];
        int [] secretMap = new int[n];
        for(int i = 0; i &lt; n; i++) {
            secretMap[i] = arr1[i] | arr2[i];
            answer[i] = makeSharp(secretMap[i], n);
        }
        return answer;
    }
}</code></pre>]]></description>
        </item>
        <item>
            <title><![CDATA[[프로그래머스] 2016년 - Java]]></title>
            <link>https://velog.io/@yewon_s/%ED%94%84%EB%A1%9C%EA%B7%B8%EB%9E%98%EB%A8%B8%EC%8A%A4-2016%EB%85%84-Java</link>
            <guid>https://velog.io/@yewon_s/%ED%94%84%EB%A1%9C%EA%B7%B8%EB%9E%98%EB%A8%B8%EC%8A%A4-2016%EB%85%84-Java</guid>
            <pubDate>Mon, 31 Oct 2022 13:45:31 GMT</pubDate>
            <description><![CDATA[<h3 id="문제-설명"><strong>문제 설명</strong></h3>
<p>2016년 1월 1일은 금요일입니다. 2016년 a월 b일은 무슨 요일일까요? 두 수 a ,b를 입력받아 2016년 a월 b일이 무슨 요일인지 리턴하는 함수, solution을 완성하세요. 요일의 이름은 일요일부터 토요일까지 각각 SUN,MON,TUE,WED,THU,FRI,SAT</p>
<p>입니다. 예를 들어 a=5, b=24라면 5월 24일은 화요일이므로 문자열 &quot;TUE&quot;를 반환하세요.</p>
<h4 id="제한-조건">제한 조건</h4>
<ul>
<li>2016년은 윤년입니다.</li>
<li>2016년 a월 b일은 실제로 있는 날입니다. (13월 26일이나 2  월 45일같은 날짜는 주어지지 않습니다)</li>
</ul>
<h3 id="풀이"><strong>풀이</strong></h3>
<pre><code>class Solution {
    public String solution(int a, int b) {
        String answer = &quot;&quot;;

        String [] day = {&quot;FRI&quot;, &quot;SAT&quot;, &quot;SUN&quot;, &quot;MON&quot;, &quot;TUE&quot;, &quot;WED&quot;, &quot;THU&quot;};    
        int [] date = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

        int temp = 0;

        for(int i = 0 ; i &lt; a - 1 ; i ++){            
            temp += date[i];                       
        }
        temp += (b-1);
        answer = day[temp % 7];

        return answer;
    }
}</code></pre>]]></description>
        </item>
        <item>
            <title><![CDATA[[프로그래머스] 체육복 - Java]]></title>
            <link>https://velog.io/@yewon_s/%ED%94%84%EB%A1%9C%EA%B7%B8%EB%9E%98%EB%A8%B8%EC%8A%A4-%EC%B2%B4%EC%9C%A1%EB%B3%B5-Java</link>
            <guid>https://velog.io/@yewon_s/%ED%94%84%EB%A1%9C%EA%B7%B8%EB%9E%98%EB%A8%B8%EC%8A%A4-%EC%B2%B4%EC%9C%A1%EB%B3%B5-Java</guid>
            <pubDate>Mon, 10 Oct 2022 13:16:34 GMT</pubDate>
            <description><![CDATA[<h3 id="문제-설명"><strong>문제 설명</strong></h3>
<ul>
<li><p>점심시간에 도둑이 들어, 일부 학생이 체육복을 도난당했습니다. 다행히 여벌 체육복이 있는 학생이 이들에게 체육복을 빌려주려 합니다. 학생들의 번호는 체격 순으로 매겨져 있어, 바로 앞번호의 학생이나 바로 뒷번호의 학생에게만 체육복을 빌려줄 수 있습니다. 예를 들어, 4번 학생은 3번 학생이나 5번 학생에게만 체육복을 빌려줄 수 있습니다. 체육복이 없으면 수업을 들을 수 없기 때문에 체육복을 적절히 빌려 최대한 많은 학생이 체육수업을 들어야 합니다.</p>
</li>
<li><p>전체 학생의 수 n, 체육복을 도난당한 학생들의 번호가 담긴 배열 lost, 여벌의 체육복을 가져온 학생들의 번호가 담긴 배열 reserve가 매개변수로 주어질 때, 체육수업을 들을 수 있는 학생의 최댓값을 return 하도록 solution 함수를 작성해주세요.</p>
</li>
<li><p>제한사항</p>
</li>
<li><p>전체 학생의 수는 2명 이상 30명 이하입니다.</p>
</li>
<li><p>체육복을 도난당한 학생의 수는 1명 이상 n명 이하이고 중복되는 번호는 없습니다.</p>
</li>
<li><p>여벌의 체육복을 가져온 학생의 수는 1명 이상 n명 이하이고 중복되는 번호는 없습니다.</p>
</li>
<li><p>여벌 체육복이 있는 학생만 다른 학생에게 체육복을 빌려줄 수 있습니다.</p>
</li>
<li><p>여벌 체육복을 가져온 학생이 체육복을 도난당했을 수 있습니다. 이때 이 학생은 체육복을 하나만 도난당했다고 가정하며, 남은 체육복이 하나이기에 다른 학생에게는 체육복을 빌려줄 수 없습니다.</p>
</li>
</ul>
<h3 id="풀이"><strong>풀이</strong></h3>
<pre><code>import java.util.Arrays;

class Solution {
    public int solution(int n, int[] lost, int[] reserve) {
        int answer = n - lost.length;

        Arrays.sort(lost);
        Arrays.sort(reserve);

        for(int i = 0; i &lt; lost.length; i ++){
            for(int j = 0; j &lt; reserve.length; j++){
                if(lost[i] == reserve[j]){
                    answer++;
                    lost[i] = -1;
                    reserve[j] = -1;
                    break;
                }
            }
        }

        for(int i = 0; i &lt; lost.length; i ++){
            for(int j = 0; j &lt; reserve.length; j++){
                if(lost[i] -1 == reserve[j] || lost[i]+1 == reserve[j]){
                    answer++;
                    reserve[j] = -1;
                    break;
                }
            }
        }        

        return answer;
    }
}</code></pre><h3 id="다른-사람의-풀이"><strong>다른 사람의 풀이</strong></h3>
<pre><code>class Solution {
    public int solution(int n, int[] lost, int[] reserve) {
        int[] people = new int[n];
        int answer = n;

        for (int l : lost) 
            people[l-1]--;
        for (int r : reserve) 
            people[r-1]++;

        for (int i = 0; i &lt; people.length; i++) {
            if(people[i] == -1) {
                if(i-1&gt;=0 &amp;&amp; people[i-1] == 1) {
                    people[i]++;
                    people[i-1]--;
                }else if(i+1&lt; people.length &amp;&amp; people[i+1] == 1) {
                    people[i]++;
                    people[i+1]--;
                }else 
                    answer--;
            }
        }
        return answer;
    }
}</code></pre>]]></description>
        </item>
        <item>
            <title><![CDATA[[프로그래머스] 완주하지 못한 선수 - Java]]></title>
            <link>https://velog.io/@yewon_s/%ED%94%84%EB%A1%9C%EA%B7%B8%EB%9E%98%EB%A8%B8%EC%8A%A4-%EC%99%84%EC%A3%BC%ED%95%98%EC%A7%80-%EB%AA%BB%ED%95%9C-%EC%84%A0%EC%88%98-Java</link>
            <guid>https://velog.io/@yewon_s/%ED%94%84%EB%A1%9C%EA%B7%B8%EB%9E%98%EB%A8%B8%EC%8A%A4-%EC%99%84%EC%A3%BC%ED%95%98%EC%A7%80-%EB%AA%BB%ED%95%9C-%EC%84%A0%EC%88%98-Java</guid>
            <pubDate>Thu, 06 Oct 2022 15:23:19 GMT</pubDate>
            <description><![CDATA[<h3 id="문제-설명"><strong>문제 설명</strong></h3>
<ul>
<li><p>수많은 마라톤 선수들이 마라톤에 참여하였습니다. 단 한 명의 선수를 제외하고는 모든 선수가 마라톤을 완주하였습니다.</p>
</li>
<li><p>마라톤에 참여한 선수들의 이름이 담긴 배열 participant와 완주한 선수들의 이름이 담긴 배열 completion이 주어질 때, 완주하지 못한 선수의 이름을 return 하도록 solution 함수를 작성해주세요.</p>
</li>
<li><p>제한사항
마라톤 경기에 참여한 선수의 수는 1명 이상 100,000명 이하입니다.
completion의 길이는 participant의 길이보다 1 작습니다.
참가자의 이름은 1개 이상 20개 이하의 알파벳 소문자로 이루어져 있습니다.
참가자 중에는 동명이인이 있을 수 있습니다.</p>
</li>
</ul>
<h3 id="풀이"><strong>풀이</strong></h3>
<pre><code>import java.util.Arrays;

class Solution {
    public String solution(String[] participant, String[] completion) {
        String answer = &quot;&quot;;

        Arrays.sort(participant);
        Arrays.sort(completion);
        int i;
        for(i = 0; i &lt; completion.length; i ++){
            if(!participant[i].equals(completion[i])){
                return participant[i];
            }
        }

        return participant[i];
    }
}</code></pre><h3 id="다른-사람의-풀이"><strong>다른 사람의 풀이</strong></h3>
<pre><code>import java.util.HashMap;

class Solution {
    public String solution(String[] participant, String[] completion) {
        String answer = &quot;&quot;;
        HashMap&lt;String, Integer&gt; hm = new HashMap&lt;&gt;();
        for (String player : participant) hm.put(player, hm.getOrDefault(player, 0) + 1);
        for (String player : completion) hm.put(player, hm.get(player) - 1);

        for (String key : hm.keySet()) {
            if (hm.get(key) != 0){
                answer = key;
            }
        }
        return answer;
    }
}</code></pre>]]></description>
        </item>
        <item>
            <title><![CDATA[[프로그래머스] 폰켓몬 -Java]]></title>
            <link>https://velog.io/@yewon_s/xej9k2pj</link>
            <guid>https://velog.io/@yewon_s/xej9k2pj</guid>
            <pubDate>Thu, 06 Oct 2022 14:39:03 GMT</pubDate>
            <description><![CDATA[<h3 id="문제-설명"><strong>문제 설명</strong></h3>
<ul>
<li>당신은 폰켓몬을 잡기 위한 오랜 여행 끝에, 홍 박사님의 연구실에 도착했습니다. </li>
<li>홍 박사님은 당신에게 자신의 연구실에 있는 총 N 마리의 폰켓몬 중에서 N/2마리를 가져가도 좋다고 했습니다.</li>
<li>홍 박사님 연구실의 폰켓몬은 종류에 따라 번호를 붙여 구분합니다. 따라서 같은 종류의 폰켓몬은 같은 번호를 가지고 있습니다. 예를 들어 연구실에 총 4마리의 폰켓몬이 있고, 각 폰켓몬의 종류 번호가 [3번, 1번, 2번, 3번]이라면 이는 3번 폰켓몬 두 마리, 1번 폰켓몬 한 마리, 2번 폰켓몬 한 마리가 있음을 나타냅니다. 이때, 4마리의 폰켓몬 중 2마리를 고르는 방법은 다음과 같이 6가지가 있습니다.</li>
</ul>
<ol>
<li>첫 번째(3번), 두 번째(1번) 폰켓몬을 선택</li>
<li>첫 번째(3번), 세 번째(2번) 폰켓몬을 선택</li>
<li>첫 번째(3번), 네 번째(3번) 폰켓몬을 선택</li>
<li>두 번째(1번), 세 번째(2번) 폰켓몬을 선택</li>
<li>두 번째(1번), 네 번째(3번) 폰켓몬을 선택</li>
<li>세 번째(2번), 네 번째(3번) 폰켓몬을 선택</li>
</ol>
<ul>
<li>이때, 첫 번째(3번) 폰켓몬과 네 번째(3번) 폰켓몬을 선택하는 방법은 한 종류(3번 폰켓몬 두 마리)의 폰켓몬만 가질 수 있지만, 다른 방법들은 모두 두 종류의 폰켓몬을 가질 수 있습니다. 따라서 위 예시에서 가질 수 있는 폰켓몬 종류 수의 최댓값은 2가 됩니다.</li>
<li>당신은 최대한 다양한 종류의 폰켓몬을 가지길 원하기 때문에, 최대한 많은 종류의 폰켓몬을 포함해서 N/2마리를 선택하려 합니다. N마리 폰켓몬의 종류 번호가 담긴 배열 nums가 매개변수로 주어질 때, N/2마리의 폰켓몬을 선택하는 방법 중, 가장 많은 종류의 폰켓몬을 선택하는 방법을 찾아, 그때의 폰켓몬 종류 번호의 개수를 return 하도록 solution 함수를 완성해주세요.</li>
</ul>
<h3 id="풀이"><strong>풀이</strong></h3>
<pre><code>import java.util.HashSet;

class Solution {
    public int solution(int[] nums) {
        int answer = 0;

        int pick = nums.length/2;

        HashSet&lt;Integer&gt; set = new HashSet&lt;&gt;();

        for(int n : nums){
            set.add(n);
        }

        if(pick &gt;= set.size()){
            answer = set.size();
        }
        else
            answer = pick;

        return answer;
    }
}</code></pre><h3 id="다른-사람의-풀이"><strong>다른 사람의 풀이</strong></h3>
<pre><code>import java.util.Arrays;
import java.util.stream.Collectors;

class Solution {
    public int solution(int[] nums) {
        return Arrays.stream(nums)
                .boxed()
                .collect(Collectors.collectingAndThen(Collectors.toSet(),
                        phonekemons -&gt; Integer.min(phonekemons.size(), nums.length / 2)));
    }
}</code></pre>]]></description>
        </item>
        <item>
            <title><![CDATA[[프로그래머스] 두 개 뽑아서 더하기]]></title>
            <link>https://velog.io/@yewon_s/%ED%94%84%EB%A1%9C%EA%B7%B8%EB%9E%98%EB%A8%B8%EC%8A%A4-%EB%91%90-%EA%B0%9C-%EB%BD%91%EC%95%84%EC%84%9C-%EB%8D%94%ED%95%98%EA%B8%B0</link>
            <guid>https://velog.io/@yewon_s/%ED%94%84%EB%A1%9C%EA%B7%B8%EB%9E%98%EB%A8%B8%EC%8A%A4-%EB%91%90-%EA%B0%9C-%EB%BD%91%EC%95%84%EC%84%9C-%EB%8D%94%ED%95%98%EA%B8%B0</guid>
            <pubDate>Wed, 05 Oct 2022 15:39:41 GMT</pubDate>
            <description><![CDATA[<h3 id="문제-설명"><strong>문제 설명</strong></h3>
<ul>
<li>정수 배열 numbers가 주어집니다. numbers에서 서로 다른 인덱스에 있는 두 개의 수를 뽑아 더해서 만들 수 있는 모든 수를 배열에 오름차순으로 담아 return 하도록 solution 함수를 완성해주세요.</li>
</ul>
<h3 id="풀이"><strong>풀이</strong></h3>
<pre><code>import java.util.*;

class Solution {
    public int[] solution(int[] numbers) {

        int temp = 0;
        ArrayList&lt;Integer&gt; arrays = new ArrayList&lt;&gt;();

        for(int i = 0; i &lt; numbers.length; i++){
            for(int j = i+1; j &lt; numbers.length; j++){
                temp = numbers[i]+numbers[j];
                if(!arrays.contains(temp))
                    arrays.add(temp);
            }
        }

        Collections.sort(arrays);
        int[] answer = new int [arrays.size()];
        for(int i = 0; i &lt; arrays.size(); i++){
            answer[i] = arrays.get(i);
        }

        return answer;
    }
}</code></pre><h3 id="다른-사람의-풀이"><strong>다른 사람의 풀이</strong></h3>
<pre><code>import java.util.HashSet;
import java.util.Set;

class Solution {
     public int[] solution(int[] numbers) {
        Set&lt;Integer&gt; set = new HashSet&lt;&gt;();

        for(int i=0; i&lt;numbers.length; i++) {
            for(int j=i+1; j&lt;numbers.length; j++) {
                set.add(numbers[i] + numbers[j]);
            }
        }

        return set.stream().sorted().mapToInt(Integer::intValue).toArray();
    }
}</code></pre>]]></description>
        </item>
        <item>
            <title><![CDATA[[프로그래머스] 문자열 내 마음대로 정렬하기 - Java]]></title>
            <link>https://velog.io/@yewon_s/%ED%94%84%EB%A1%9C%EA%B7%B8%EB%9E%98%EB%A8%B8%EC%8A%A4-%EB%AC%B8%EC%9E%90%EC%97%B4-%EB%82%B4-%EB%A7%88%EC%9D%8C%EB%8C%80%EB%A1%9C-%EC%A0%95%EB%A0%AC%ED%95%98%EA%B8%B0-Java</link>
            <guid>https://velog.io/@yewon_s/%ED%94%84%EB%A1%9C%EA%B7%B8%EB%9E%98%EB%A8%B8%EC%8A%A4-%EB%AC%B8%EC%9E%90%EC%97%B4-%EB%82%B4-%EB%A7%88%EC%9D%8C%EB%8C%80%EB%A1%9C-%EC%A0%95%EB%A0%AC%ED%95%98%EA%B8%B0-Java</guid>
            <pubDate>Wed, 05 Oct 2022 15:18:10 GMT</pubDate>
            <description><![CDATA[<h3 id="문제-설명"><strong>문제 설명</strong></h3>
<ul>
<li><p>문자열로 구성된 리스트 strings와, 정수 n이 주어졌을 때, 각 문자열의 인덱스 n번째 글자를 기준으로 오름차순 정렬하려 합니다. 예를 들어 strings가 [&quot;sun&quot;, &quot;bed&quot;, &quot;car&quot;]이고 n이 1이면 각 단어의 인덱스 1의 문자 &quot;u&quot;, &quot;e&quot;, &quot;a&quot;로 strings를 정렬합니다.</p>
<ul>
<li>제한 조건
strings는 길이 1 이상, 50이하인 배열입니다.
strings의 원소는 소문자 알파벳으로 이루어져 있습니다.
strings의 원소는 길이 1 이상, 100이하인 문자열입니다.
모든 strings의 원소의 길이는 n보다 큽니다.
인덱스 1의 문자가 같은 문자열이 여럿 일 경우, 사전순으로 앞선 문자열이 앞쪽에 위치합니다.</li>
</ul>
</li>
</ul>
<h3 id="풀이"><strong>풀이</strong></h3>
<pre><code>import java.util.*;

class Solution {
    public String[] solution(String[] strings, int n) {
        String[] answer = new String[strings.length];

        ArrayList&lt;String&gt; array = new ArrayList&lt;String&gt; ();

        for(int i = 0; i &lt; strings.length; i++){
            array.add(strings[i].charAt(n)+strings[i]);
        }

        Collections.sort(array);

        for(int i = 0 ; i &lt; array.size(); i ++){
            answer[i] = array.get(i).substring(1);
        }

        return answer;
    }
}</code></pre><h3 id="다른-사람의-풀이"><strong>다른 사람의 풀이</strong></h3>
<pre><code>import java.util.*;

class Solution {
    public String[] solution(String[] strings, int n) {
        String[] answer = {};
        ArrayList&lt;String&gt; arr = new ArrayList&lt;&gt;();
        for (int i = 0; i &lt; strings.length; i++) {
            arr.add(&quot;&quot; + strings[i].charAt(n) + strings[i]);
        }
        Collections.sort(arr);
        answer = new String[arr.size()];
        for (int i = 0; i &lt; arr.size(); i++) {
            answer[i] = arr.get(i).substring(1, arr.get(i).length());
        }
        return answer;
    }
}</code></pre>]]></description>
        </item>
        <item>
            <title><![CDATA[[프로그래머스] 숫자 문자열과 영단어 - Java]]></title>
            <link>https://velog.io/@yewon_s/%ED%94%84%EB%A1%9C%EA%B7%B8%EB%9E%98%EB%A8%B8%EC%8A%A4-%EC%88%AB%EC%9E%90-%EB%AC%B8%EC%9E%90%EC%97%B4%EA%B3%BC-%EC%98%81%EB%8B%A8%EC%96%B4-Java</link>
            <guid>https://velog.io/@yewon_s/%ED%94%84%EB%A1%9C%EA%B7%B8%EB%9E%98%EB%A8%B8%EC%8A%A4-%EC%88%AB%EC%9E%90-%EB%AC%B8%EC%9E%90%EC%97%B4%EA%B3%BC-%EC%98%81%EB%8B%A8%EC%96%B4-Java</guid>
            <pubDate>Mon, 03 Oct 2022 14:05:21 GMT</pubDate>
            <description><![CDATA[<h3 id="문제-설명"><strong>문제 설명</strong></h3>
<ul>
<li><p>네오와 프로도가 숫자놀이를 하고 있습니다. 네오가 프로도에게 숫자를 건넬 때 일부 자릿수를 영단어로 바꾼 카드를 건네주면 프로도는 원래 숫자를 찾는 게임입니다.</p>
</li>
<li><p>다음은 숫자의 일부 자릿수를 영단어로 바꾸는 예시입니다.
1478 → &quot;one4seveneight&quot;
234567 → &quot;23four5six7&quot;
10203 → &quot;1zerotwozero3&quot;
이렇게 숫자의 일부 자릿수가 영단어로 바뀌어졌거나, 혹은 바뀌지 않고 그대로인 문자열 s가 매개변수로 주어집니다. s가 의미하는 원래 숫자를 return 하도록 solution 함수를 완성해주세요.</p>
</li>
</ul>
<h3 id="풀이"><strong>풀이</strong></h3>
<pre><code>import java.util.*;

class Solution {
    public int solution(String s) {
        String [] num = {&quot;zero&quot;,&quot;one&quot;,&quot;two&quot;,&quot;three&quot;,&quot;four&quot;,&quot;five&quot;,&quot;six&quot;,&quot;seven&quot;,&quot;eight&quot;, &quot;nine&quot;}; 

        for(int i = 0; i &lt; 10; i ++)
        {
            s = s.replace(num[i], Integer.toString(i));
        }        
        return Integer.parseInt(s);
    }
}</code></pre><h3 id="다른-사람의-풀이"><strong>다른 사람의 풀이</strong></h3>
<pre><code>import java.util.*;

class Solution {
    public int solution(String s) {
        int answer = 0;
        StringBuilder sb = new StringBuilder(&quot;&quot;);
        int len = s.length();
        String[] digits = {&quot;0&quot;,&quot;1&quot;,&quot;2&quot;,&quot;3&quot;,&quot;4&quot;,&quot;5&quot;,&quot;6&quot;,&quot;7&quot;,&quot;8&quot;,&quot;9&quot;};
        String[] alphabets = {&quot;zero&quot;,&quot;one&quot;,&quot;two&quot;,&quot;three&quot;,&quot;four&quot;,&quot;five&quot;,&quot;six&quot;,&quot;seven&quot;,&quot;eight&quot;,&quot;nine&quot;};

        for(int i=0; i&lt;10; i++){
            s = s.replaceAll(alphabets[i],digits[i]);
        }

        return Integer.parseInt(s);
    }
}</code></pre>]]></description>
        </item>
        <item>
            <title><![CDATA[[프로그래머스] 최소직사각형 - Java]]></title>
            <link>https://velog.io/@yewon_s/%ED%94%84%EB%A1%9C%EA%B7%B8%EB%9E%98%EB%A8%B8%EC%8A%A4-%EC%B5%9C%EC%86%8C%EC%A7%81%EC%82%AC%EA%B0%81%ED%98%95-Java</link>
            <guid>https://velog.io/@yewon_s/%ED%94%84%EB%A1%9C%EA%B7%B8%EB%9E%98%EB%A8%B8%EC%8A%A4-%EC%B5%9C%EC%86%8C%EC%A7%81%EC%82%AC%EA%B0%81%ED%98%95-Java</guid>
            <pubDate>Mon, 03 Oct 2022 13:23:08 GMT</pubDate>
            <description><![CDATA[<h3 id="문제-설명"><strong>문제 설명</strong></h3>
<ul>
<li><p>명함 지갑을 만드는 회사에서 지갑의 크기를 정하려고 합니다. 다양한 모양과 크기의 명함들을 모두 수납할 수 있으면서, 작아서 들고 다니기 편한 지갑을 만들어야 합니다. 이러한 요건을 만족하는 지갑을 만들기 위해 디자인팀은 모든 명함의 가로 길이와 세로 길이를 조사했습니다.</p>
</li>
<li><p>아래 표는 4가지 명함의 가로 길이와 세로 길이를 나타냅니다.</p>
</li>
</ul>
<p>명함 번호    가로 길이    세로 길이
1           60          50
2           30          70
3           60          30
4           80          40</p>
<ul>
<li><p>가장 긴 가로 길이와 세로 길이가 각각 80, 70이기 때문에 80(가로) x 70(세로) 크기의 지갑을 만들면 모든 명함들을 수납할 수 있습니다. 하지만 2번 명함을 가로로 눕혀 수납한다면 80(가로) x 50(세로) 크기의 지갑으로 모든 명함들을 수납할 수 있습니다. 이때의 지갑 크기는 4000(=80 x 50)입니다.</p>
</li>
<li><p>모든 명함의 가로 길이와 세로 길이를 나타내는 2차원 배열 sizes가 매개변수로 주어집니다. 모든 명함을 수납할 수 있는 가장 작은 지갑을 만들 때, 지갑의 크기를 return 하도록 solution 함수를 완성해주세요.</p>
</li>
</ul>
<h3 id="풀이"><strong>풀이</strong></h3>
<pre><code>import java.util.*;

class Solution {
    public int solution(int[][] sizes) {
        int answer = 0;
        int max_v=0;
        int max_h=0;
        for(int i=0; i &lt; sizes.length; i++){
            int v = Math.max(sizes[i][0],sizes[i][1]);
            int h = Math.min(sizes[i][0],sizes[i][1]);
            max_v = Math.max(max_v,v);
            max_h = Math.max(max_h,h);
        }
        return answer=max_v*max_h;
    }
}</code></pre><h3 id="다른-사람의-풀이"><strong>다른 사람의 풀이</strong></h3>
<pre><code>import java.util.*;
class Solution {
    public int solution(int[][] sizes) {
        return Arrays.stream(sizes).reduce((a, b) -&gt; new int[]{
                Math.max(Math.max(a[0], a[1]), Math.max(b[0], b[1])), Math.max(Math.min(a[0], a[1]), Math.min(b[0], b[1]))
        }).map(it -&gt; it[0] * it[1]).get();
    }
}</code></pre><pre><code>class Solution {
    public int solution(int[][] sizes) {
        int length = 0, height = 0;
        for (int[] card : sizes) {
            length = Math.max(length, Math.max(card[0], card[1]));
            height = Math.max(height, Math.min(card[0], card[1]));
        }
        int answer = length * height;
        return answer;
    }
}</code></pre>]]></description>
        </item>
        <item>
            <title><![CDATA[[프로그래머스] 예산 - Java]]></title>
            <link>https://velog.io/@yewon_s/%ED%94%84%EB%A1%9C%EA%B7%B8%EB%9E%98%EB%A8%B8%EC%8A%A4-%EC%98%88%EC%82%B0-Java</link>
            <guid>https://velog.io/@yewon_s/%ED%94%84%EB%A1%9C%EA%B7%B8%EB%9E%98%EB%A8%B8%EC%8A%A4-%EC%98%88%EC%82%B0-Java</guid>
            <pubDate>Mon, 03 Oct 2022 13:06:33 GMT</pubDate>
            <description><![CDATA[<h3 id="문제-설명"><strong>문제 설명</strong></h3>
<ul>
<li><p>S사에서는 각 부서에 필요한 물품을 지원해 주기 위해 부서별로 물품을 구매하는데 필요한 금액을 조사했습니다. 그러나, 전체 예산이 정해져 있기 때문에 모든 부서의 물품을 구매해 줄 수는 없습니다. 그래서 최대한 많은 부서의 물품을 구매해 줄 수 있도록 하려고 합니다.</p>
</li>
<li><p>물품을 구매해 줄 때는 각 부서가 신청한 금액만큼을 모두 지원해 줘야 합니다. 예를 들어 1,000원을 신청한 부서에는 정확히 1,000원을 지원해야 하며, 1,000원보다 적은 금액을 지원해 줄 수는 없습니다.</p>
</li>
<li><p>부서별로 신청한 금액이 들어있는 배열 d와 예산 budget이 매개변수로 주어질 때, 최대 몇 개의 부서에 물품을 지원할 수 있는지 return 하도록 solution 함수를 완성해주세요</p>
</li>
</ul>
<h3 id="풀이"><strong>풀이</strong></h3>
<pre><code>import java.util.Arrays;

class Solution {
    public int solution(int[] d, int budget) {
        int answer = 0;
        Arrays.sort(d);
        for(int i = 0; i &lt; d.length; i ++){
            budget -= d[i];

            if (budget &lt; 0)
                break;
            answer++;
        }

        return answer;
    }
}</code></pre>]]></description>
        </item>
        <item>
            <title><![CDATA[[프로그래머스] 3진법 뒤집기 - Java]]></title>
            <link>https://velog.io/@yewon_s/%ED%94%84%EB%A1%9C%EA%B7%B8%EB%9E%98%EB%A8%B8%EC%8A%A4-3%EC%A7%84%EB%B2%95-%EB%92%A4%EC%A7%91%EA%B8%B0-Java</link>
            <guid>https://velog.io/@yewon_s/%ED%94%84%EB%A1%9C%EA%B7%B8%EB%9E%98%EB%A8%B8%EC%8A%A4-3%EC%A7%84%EB%B2%95-%EB%92%A4%EC%A7%91%EA%B8%B0-Java</guid>
            <pubDate>Wed, 28 Sep 2022 13:46:05 GMT</pubDate>
            <description><![CDATA[<h3 id="문제-설명"><strong>문제 설명</strong></h3>
<ul>
<li>자연수 n이 매개변수로 주어집니다. </li>
<li>n을 3진법 상에서 앞뒤로 뒤집은 후, 이를 다시 10진법으로 표현한 수를 return 하도록 solution 함수를 완성해주세요.</li>
</ul>
<h3 id="풀이"><strong>풀이</strong></h3>
<pre><code>import java.util.ArrayList;

class Solution {
    public int solution(int n) {
        int answer = 0;
        ArrayList&lt;Integer&gt; temp = new ArrayList&lt;Integer&gt;();
        while(n &gt; 0)
        {
            temp.add(n % 3);
            n /= 3;

        }
        int cnt = 1;
        for(int i = temp.size()-1; i &gt;= 0; i --){
            answer += temp.get(i) * cnt;
            cnt *= 3;
        }

        System.out.println(answer);
        return answer;
    }
}</code></pre><h3 id="다른-사람의-풀이"><strong>다른 사람의 풀이</strong></h3>
<pre><code>class Solution {
    public int solution(int n) {
        String a = &quot;&quot;;

        while(n &gt; 0){
            a = (n % 3) + a;
            n /= 3;
        }
        a = new StringBuilder(a).reverse().toString();

        return Integer.parseInt(a,3);
    }
}</code></pre>]]></description>
        </item>
        <item>
            <title><![CDATA[[프로그래머스] 음양더하기 - Java]]></title>
            <link>https://velog.io/@yewon_s/%ED%94%84%EB%A1%9C%EA%B7%B8%EB%9E%98%EB%A8%B8%EC%8A%A4-%EC%9D%8C%EC%96%91%EB%8D%94%ED%95%98%EA%B8%B0-Java</link>
            <guid>https://velog.io/@yewon_s/%ED%94%84%EB%A1%9C%EA%B7%B8%EB%9E%98%EB%A8%B8%EC%8A%A4-%EC%9D%8C%EC%96%91%EB%8D%94%ED%95%98%EA%B8%B0-Java</guid>
            <pubDate>Wed, 28 Sep 2022 13:26:05 GMT</pubDate>
            <description><![CDATA[<h3 id="문제-설명"><strong>문제 설명</strong></h3>
<ul>
<li>어떤 정수들이 있습니다. </li>
<li>이 정수들의 절댓값을 차례대로 담은 정수 배열 absolutes와 이 정수들의 부호를 차례대로 담은 불리언 배열 signs가 매개변수로 주어집니다. </li>
<li>실제 정수들의 합을 구하여 return 하도록 solution 함수를 완성해주세요.</li>
</ul>
<h3 id="풀이"><strong>풀이</strong></h3>
<pre><code>class Solution {
    public int solution(int[] absolutes, boolean[] signs) {
        int answer = 0;
        for(int i = 0; i &lt; absolutes.length; i++)
        {
            if(signs[i])
               answer += absolutes[i] * 1;
            else
               answer += absolutes[i] * (-1);
        }
        return answer;
    }
}</code></pre><h3 id="다른-사람의-풀이"><strong>다른 사람의 풀이</strong></h3>
<pre><code>class Solution {
    public int solution(int[] absolutes, boolean[] signs) {
        int answer = 0;
        for (int i=0; i&lt;signs.length; i++)
            answer += absolutes[i] * (signs[i]? 1: -1);
        return answer;
    }
}</code></pre>]]></description>
        </item>
        <item>
            <title><![CDATA[[프로그래머스] 약수의 개수와 덧셈 - Java]]></title>
            <link>https://velog.io/@yewon_s/%ED%94%84%EB%A1%9C%EA%B7%B8%EB%9E%98%EB%A8%B8%EC%8A%A4-%EC%95%BD%EC%88%98%EC%9D%98-%EA%B0%9C%EC%88%98%EC%99%80-%EB%8D%A7%EC%85%88-Java</link>
            <guid>https://velog.io/@yewon_s/%ED%94%84%EB%A1%9C%EA%B7%B8%EB%9E%98%EB%A8%B8%EC%8A%A4-%EC%95%BD%EC%88%98%EC%9D%98-%EA%B0%9C%EC%88%98%EC%99%80-%EB%8D%A7%EC%85%88-Java</guid>
            <pubDate>Wed, 28 Sep 2022 13:09:31 GMT</pubDate>
            <description><![CDATA[<h3 id="문제-설명"><strong>문제 설명</strong></h3>
<ul>
<li>두 정수 left와 right가 매개변수로 주어집니다. </li>
<li>left부터 right까지의 모든 수들 중에서, 약수의 개수가 짝수인 수는 더하고, 약수의 개수가 홀수인 수는 뺀 수를 return 하도록 solution 함수를 완성해주세요.</li>
</ul>
<h3 id="풀이"><strong>풀이</strong></h3>
<pre><code>class Solution {
    public int solution(int left, int right) {
        int answer = 0;
        for(int i = left; i &lt;= right; i++){
            int temp = 0;
            for(int j = 1 ; j &lt;= i; j++){
                if(i % j == 0)
                   temp++;
            }
            if(temp % 2 == 0)
               answer += i;
            else
               answer -= i;            
        }
        return answer;
    }
}</code></pre><h3 id="다른-사람의-풀이"><strong>다른 사람의 풀이</strong></h3>
<pre><code>class Solution {
    public int solution(int left, int right) {
        int answer = 0;

        for (int i=left;i&lt;=right;i++) {
            //제곱수인 경우 약수의 개수가 홀수
            if (i % Math.sqrt(i) == 0) {
                answer -= i;
            }
            //제곱수가 아닌 경우 약수의 개수가 짝수
            else {
                answer += i;
            }
        }

        return answer;
    }
}</code></pre>]]></description>
        </item>
        <item>
            <title><![CDATA[[프로그래머스] 내적 - Java]]></title>
            <link>https://velog.io/@yewon_s/%ED%94%84%EB%A1%9C%EA%B7%B8%EB%9E%98%EB%A8%B8%EC%8A%A4-%EB%82%B4%EC%A0%81-Java</link>
            <guid>https://velog.io/@yewon_s/%ED%94%84%EB%A1%9C%EA%B7%B8%EB%9E%98%EB%A8%B8%EC%8A%A4-%EB%82%B4%EC%A0%81-Java</guid>
            <pubDate>Tue, 27 Sep 2022 15:05:05 GMT</pubDate>
            <description><![CDATA[<h3 id="문제-설명"><strong>문제 설명</strong></h3>
<ul>
<li>길이가 같은 두 1차원 정수 배열 a, b가 매개변수로 주어집니다. a와 b의 내적을 return 하도록 solution 함수를 완성해주세요.</li>
<li>이때, a와 b의 내적은 a[0]<em>b[0] + a[1]</em>b[1] + ... + a[n-1]*b[n-1] 입니다. (n은 a, b의 길이)</li>
</ul>
<h3 id="풀이"><strong>풀이</strong></h3>
<pre><code>class Solution {
    public int solution(int[] a, int[] b) {
        int answer = 0;

        for(int i = 0; i &lt; a.length; i++){
            answer += (a[i]*b[i]);
        }

        return answer;
    }
}</code></pre><h3 id="다른-사람의-풀이"><strong>다른 사람의 풀이</strong></h3>
<pre><code>import java.util.stream.IntStream;

class Solution {
    public int solution(int[] a, int[] b) {
        return IntStream.range(0, a.length).map(index -&gt; a[index] * b[index]).sum();
    }
}</code></pre>]]></description>
        </item>
        <item>
            <title><![CDATA[[프로그래머스] 문자열 내림차순으로 배치하기 - Java]]></title>
            <link>https://velog.io/@yewon_s/%ED%94%84%EB%A1%9C%EA%B7%B8%EB%9E%98%EB%A8%B8%EC%8A%A4-%EB%AC%B8%EC%9E%90%EC%97%B4-%EB%82%B4%EB%A6%BC%EC%B0%A8%EC%88%9C%EC%9C%BC%EB%A1%9C-%EB%B0%B0%EC%B9%98%ED%95%98%EA%B8%B0-Java</link>
            <guid>https://velog.io/@yewon_s/%ED%94%84%EB%A1%9C%EA%B7%B8%EB%9E%98%EB%A8%B8%EC%8A%A4-%EB%AC%B8%EC%9E%90%EC%97%B4-%EB%82%B4%EB%A6%BC%EC%B0%A8%EC%88%9C%EC%9C%BC%EB%A1%9C-%EB%B0%B0%EC%B9%98%ED%95%98%EA%B8%B0-Java</guid>
            <pubDate>Tue, 27 Sep 2022 14:57:44 GMT</pubDate>
            <description><![CDATA[<h3 id="문제-설명"><strong>문제 설명</strong></h3>
<ul>
<li>문자열 s에 나타나는 문자를 큰것부터 작은 순으로 정렬해 새로운 문자열을 리턴하는 함수, solution을 완성해주세요.</li>
<li>s는 영문 대소문자로만 구성되어 있으며, 대문자는 소문자보다 작은 것으로 간주합니다.</li>
</ul>
<h3 id="풀이"><strong>풀이</strong></h3>
<pre><code>import java.util.*;
class Solution {
    public String solution(String s) {
        String answer = &quot;&quot;;
        char[] array = s.toCharArray();
        Arrays.sort(array);

        for(int i = array.length-1 ; i &gt;= 0 ; i--)
        answer += array[i];
        return answer;
    }
}</code></pre><h3 id="다른-사람의-풀이"><strong>다른 사람의 풀이</strong></h3>
<pre><code>import java.util.Arrays;

public class ReverseStr {
    public String reverseStr(String str){
    char[] sol = str.toCharArray();
    Arrays.sort(sol);
    return new StringBuilder(new String(sol)).reverse().toString();
    }

    // 아래는 테스트로 출력해 보기 위한 코드입니다.
    public static void main(String[] args) {
        ReverseStr rs = new ReverseStr();
        System.out.println( rs.reverseStr(&quot;Zbcdefg&quot;) );
    }
}</code></pre>]]></description>
        </item>
    </channel>
</rss>