목록프로그래머스/프로그래머스 LV.2 (6)
밍쎄의 코딩공간
![](http://i1.daumcdn.net/thumb/C150x150/?fname=https://blog.kakaocdn.net/dn/6dLdG/btssbCzfd0A/uzuR84W02DLe9wkybRSkE0/img.png)
문제 class Solution { public long solution(long k, long d) { long answer = 0; for(long x = 0; x
import java.util.*; class Solution { public int solution(int[] people, int limit) { int answer = 0; Arrays.sort(people); int index = 0; for (int i = people.length - 1; i >= index; i--) { if (people[i] + people[index]
소싯적에 우리는 한컴타자를 했다. ㅎㅎ 그때 광물캐기라는 코너 속 코너 게임이 있엇는디,,, 정감가드라요..~ import java.util.*; class Solution { public int solution(int[] picks, String[] minerals) { int answer = 0; int num = picks[0] + picks[1] + picks[2]; int[][] section = new int[minerals.length / 5 + 1][3]; int i, pick; for(i = 0; i 0; i++) { switch(minerals[i].charAt(0)) { case 'd': section[i / 5][0] += 1; sec..
![](http://i1.daumcdn.net/thumb/C150x150/?fname=https://blog.kakaocdn.net/dn/ugOYt/btsrYTMP7vp/aCtx6zan9xksUaRqQ1ydC1/img.png)
정수 n이 매개변수로 주어집니다. 다음 그림과 같이 밑변의 길이와 높이가 n인 삼각형에서 맨 위 꼭짓점부터 반시계 방향으로 달팽이 채우기를 진행한 후, 첫 행부터 마지막 행까지 모두 순서대로 합친 새로운 배열을 return 하도록 solution 함수를 완성해주세요. - 제한사항 제한사항 n은 1 이상 1,000 이하입니다. - 입출력 예 n result 4 [1,2,9,3,10,8,4,5,6,7] 5 [1,2,12,3,13,11,4,14,15,10,5,6,7,8,9] 6 [1,2,15,3,16,14,4,17,21,13,5,18,19,20,12,6,7,8,9,10,11] 이 문제에서는 삼각형을 표현해야 한다. 사각형인 2차원 배열을 표로 나타내면 쉽게 해결할 수 있다. 문제 조건인 반시계 방향으로 '달팽..
import java.util.*; class Solution { static char map[][]; static boolean visited[][]; static int dx[] = {1,0,-1,0}; static int dy[] = {0,1,0,-1}; static ArrayList list = new ArrayList(); public int[] solution(String[] maps) { visited = new boolean[maps.length][maps[0].length()]; map = new char[maps.length][maps[0].length()]; for(int a=0;a
import java.util.ArrayList; import java.util.Arrays; import java.util.List; class Solution { private static class Point { public final long x,y; private Point(long x, long y){ this.x = x; this.y = y; } } private Point intersection(long a1,long b1, long c1, long a2, long b2, long c2){ double x = (double) (b1 * c2 - b2 * c1)/ (a1 * b2 - a2 * b1); double y = (double) (a2 * c1 - a1 * c2)/ (a1 * b2 -..