Algorithm/Programmers

Algorithm/Programmers

[Lv.3] 표 병합

import java.util.ArrayList; import java.util.List; class Solution { static Point[][] points = new Point[51][51]; public String[] solution(String[] commands) { List answer=new ArrayList(); for (int i = 1; i

Algorithm/Programmers

[Lv.3] 표현 가능한 이진트리

import java.util.ArrayList; import java.util.LinkedList; import java.util.List; import java.util.Queue; class Solution { public int[] solution(long[] numbers) { int[] answer = new int[numbers.length]; for (int j = 0; j < numbers.length; j++) { long number = numbers[j]; String s = Long.toBinaryString(number); int length = s.length(); for (int i = 1; i < 52; i++) { double pow = Math.pow(2, i)-1; i..

Algorithm/Programmers

[Lv.3] 인사고과

import java.util.ArrayList; import java.util.List; class Solution { public int solution(int[][] scores) { int answer = 0; int a=scores[0][0]; int b=scores[0][1]; List pointList=new ArrayList(); for (int i = 1; i a&&scores[i][1]>b) return -1; if(scores[i][0]

Algorithm/Programmers

[Lv.2] 무인도 여행

import java.util.*; class Solution { public int[] solution(String[] maps) { int[] answer = {}; boolean[][] visited=new boolean[maps.length][maps[0].length()]; List ansList=new ArrayList(); //세로, 가로 Queue queue=new LinkedList(); for (int i = 0; i < maps.length; i++) { for (int j = 0; j < maps[i].length(); j++) { if(maps[i].charAt(j)!='X'&&!visited[i][j]){ queue.add(new Point(i,j)); int result=map..

Algorithm/Programmers

[Lv.3] 추석 트래픽 -자바

class Solution { public int solution(String[] lines) { int answer = 0; //overFlow? int[] msAcSum=new int[86400005]; int firstMs=99999999; int lastMs=0; for (String line : lines) { int time=0; String[] split = line.split(" "); String[] dates = split[1].split(":"); int hour=Integer.parseInt(dates[0]); time+=hour*60*60*1000; int min=Integer.parseInt(dates[1]); time+=min*60*1000; double secs = Doubl..

Algorithm/Programmers

[Lv.3] 길 찾기 게임

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..

Algorithm/Programmers

[Lv.3] [1차] 셔틀버스- JAVA

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..

Algorithm/Programmers

[Lv.3] 불량 사용자

import java.util.*; import java.util.stream.Collectors; class Solution { static Set result=new HashSet(); static String[] users; static String[] bans; public int solution(String[] user_id, String[] banned_id) { users=user_id.clone(); bans=banned_id.clone(); dfs(0,new HashSet()); return result.size(); } public boolean checkBanned(String target, String banned) { if(target.length()!=banned.length()..

시롱시롱
'Algorithm/Programmers' 카테고리의 글 목록 (5 Page)