import java.util.*; class Solution { static List preResult=new ArrayList(); static List postResult=new ArrayList(); static List pointList=new ArrayList(); public int[][] solution(int[][] nodeinfo) { for (int i = 0; i < nodeinfo.length; i++) { int[] ints = nodeinfo[i]; pointList.add(new Point(ints[0], ints[1], i + 1)); } Collections.sort(pointList); Point root= pointList.get(0); for (int i = 1; i..
import java.util.*; class Solution { public String solution(int n, int t, int m, String[] timetable) { String answer = ""; int startMin=9*60; int leaveMin=startMin+t*(n-1); List timeList=new ArrayList(); for (String s : timetable) { String[] split = s.split(":"); int time = Integer.parseInt(split[0])*60; time+=Integer.parseInt(split[1]); //마지막 차 출발 시간 이후에 줄을 서는 경우 경쟁대상이 아니다. if(time>leaveMin) co..
import java.util.Arrays; class Solution { public int solution(int n, int[] stations, int w) { int answer = 0; Arrays.sort(stations); int startPoint=1; int coverage=2*w+1; for (int i=0;i=startPoint){ int blockDis=stations[i]-w-startPoint; answer+=blockDis/coverage+1; if(blockDis%coverage==0) answer--; } startPoint=stations[i]+w+1; if(startPoint>n) break; } if(startPoint
import java.util.Arrays; import java.util.stream.Collectors; class Solution { public int solution(int[] A, int[] B) { int answer = 0; Arrays.sort(A); Arrays.sort(B); int searchIndex=-1; boolean endFlag=false; for (int i : A) { while (true){ searchIndex++; if(searchIndex>=B.length){ endFlag=true; break; } if(B[searchIndex]>i){ //현재 A가 가진 가장 낮은 패에 대해서 가장 낮은패로 승리하기 answer++; break; } } if(endFlag) ..
코테를 보든 코딩을 하든 알고 있어야 하는 자바 상식 정리 Arrays.fill(arr, value) : arr을 value값으로 초기화 한다. list.stream().mapToInt(i→i).toArray() : Collection(list)를 array로 변환 한다. 큐에 데이터를 넣는 메소드로는 add와 offer가 있는데, add의 경우 성공시 true를 반환하고 실패시 예외(IllegalStateException)를 던지고 offer의 경우 성공시 value 실패시 false를 반환한다. 클래스 equals, hash code 정의 class TMP{ int a,b; @Override public boolean equals(Object o) { if (this == o) return true;..