[프로그래머스] 숫자 변환하기 - Java
·
PS/프로그래머스
import java.util.*;class Solution { public int solution(int x, int y, int n) { int answer = 0; Queue q = new LinkedList(); q.add(new int[]{x, 0}); boolean[] visited = new boolean[y - x + 1]; while(!q.isEmpty()){ int[] curr = q.poll(); if(curr[0] == y){ return curr[1]; } ..
[프로그래머스] 도넛과 막대 그래프 - Java
·
PS/프로그래머스
import java.util.*;class Solution { List> graph; int maxVertex; boolean[] visited; boolean[] check; int[] inDegree; int startVertex; public void init(int[][] edges){ maxVertex = 0; check = new boolean[1000000]; for(int[] edge : edges){ check[edge[0]] = true; check[edge[1]] = true; maxVertex = Math...
[프로그래머스] 혼자서 하는 틱택토 - Java
·
PS/프로그래머스
class Solution { public int solution(String[] board) { String[][] board_Arr = new String[3][3]; for(int i = 0; i = 2){ return 0; } boolean check = false; boolean oWin = false; boolean xWin = false; for(int i = 0; i x){ return 0; } } } if(board..
[goorm] Dead Or Arrive - Java
·
PS/goorm
import java.io.BufferedReader;import java.io.IOException;import java.io.InputStreamReader;import java.util.Arrays;import java.util.StringTokenizer;public class DeadOrArrive { static class Car{ int v; int w; int number; public Car(int v, int w, int number){ this.v = v; this.w = w; this.number = number; } } public static ..
[백준] 구간 나누기2 - Python 13397
·
PS/백준
# 8 3# 1 5 4 6 2 1 3 7# [1, 1, 2, 3, 4, 5, 6, 7]import sysinput = sys.stdin.readlinedef check(target): global arr, M now_min = now_max = arr[0] count = 1 for i in range(len(arr)): now_min = min(now_min, arr[i]) now_max = max(now_max, arr[i]) if now_max - now_min > target: count += 1 now_max = now_min = arr[i] # print("count", count, targe..
[백준] 같이 눈사람 만들래? - Python 20366
·
PS/백준
# 5# 3 5 2 5 9## 2 3 5 5 9#import sysinput = sys.stdin.readlineT = int(input().rstrip())nums = list(map(int, input().split()))nums.sort()result = sys.maxsizefor i in range(len(nums)): for j in range(i + 3, len(nums)): l = i + 1 r = j - 1 while l abs(temp): result = abs(temp) if temp