본문 바로가기

알고리즘

(53)
[PGS] 프로그래머스 - 다리를 지나는 트럭 (JAVA) https://school.programmers.co.kr/learn/courses/30/lessons/42583 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr import java.util.*; import java.io.*; class Solution { static Queue bridge; static Queue trucks; public int solution(int bridge_length, int weight, int[] truck_weights) { int answer = 0; bridge = new LinkedList(); trucks = ..
[PGS] 프로그래머스 - 단어 변환 (JAVA) https://school.programmers.co.kr/learn/courses/30/lessons/43163 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr import java.util.*; import java.io.*; class Info{ String word; int depth; Info(String word, int depth){ this.word = word; this.depth = depth; } } class Solution { static boolean[] visited; static Queue queue; static int ans..
[PGS] 프로그래머스 : 가장 먼 노드 (JAVA) https://school.programmers.co.kr/learn/courses/30/lessons/49189 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 1. 이차원 배열로 그래프 구현 import java.util.*; import java.io.*; class Solution { static boolean[][] graph; static int n; static Queue queue; static boolean[] visited; public int solution(int n, int[][] edge) { int answer = 0; graph..
[PGS] 프로그래머스 - 체육복 (JAVA) https://school.programmers.co.kr/learn/courses/30/lessons/42862 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr import java.util.*; import java.io.*; 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
[BOJ] 6603번: 로또 (JAVA) https://www.acmicpc.net/problem/6603 6603번: 로또 입력은 여러 개의 테스트 케이스로 이루어져 있다. 각 테스트 케이스는 한 줄로 이루어져 있다. 첫 번째 수는 k (6 < k < 13)이고, 다음 k개 수는 집합 S에 포함되는 수이다. S의 원소는 오름차순으로 www.acmicpc.net import java.io.*; import java.util.*; public class Main { static int[] S; static int k; static int[] answer; static boolean[] visited; static void getNum(int x, int start){ if(x==6){ for(int i=0;i
[PGS] 프로그래머스 - 소수찾기 (JAVA) https://school.programmers.co.kr/learn/courses/30/lessons/42839# 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr import java.util.*; import java.math.*; class Solution { public static HashSet numberArr; static boolean[] visited; static String tmp; public boolean isPrime(int x){ if(x
[BOJ] 14499번: 주사위 굴리기 (JAVA) https://www.acmicpc.net/problem/14499 14499번: 주사위 굴리기 첫째 줄에 지도의 세로 크기 N, 가로 크기 M (1 ≤ N, M ≤ 20), 주사위를 놓은 곳의 좌표 x, y(0 ≤ x ≤ N-1, 0 ≤ y ≤ M-1), 그리고 명령의 개수 K (1 ≤ K ≤ 1,000)가 주어진다. 둘째 줄부터 N개의 줄에 지 www.acmicpc.net import java.io.*; import java.util.*; public class Main { static int N,M,a,b; static int[][] map; static int[] dx = {0,0,0,-1,1}; static int[] dy = {0,1,-1,0,0}; static int[] dice = new ..
[BOJ] 22233번 : 가희와 키워드 (JAVA) https://www.acmicpc.net/problem/22233 22233번: 가희와 키워드 1번째 글을 쓰고 난 후에, 메모장에 있는 키워드는 set, floyd, os가 됩니다. 2번째 글을 쓰고 난 후에, 메모장에 있는 키워드는 set, os가 됩니다. map은 1번째 글과 2번째 글에 중복으로 등장하였음을 www.acmicpc.net import java.io.*; import java.util.*; public class Main { public static void main(String[] args) throws IOException{ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokeniz..