본문 바로가기

알고리즘

(20)
[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/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/84512 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr import java.util.*; import java.io.*; class Solution { static String tmp=""; static String[] alph = {"A","E","I","O","U"}; static ArrayList voca = new ArrayList(); static void getWord(int n, int k){ if(n==k){ voca.add(tmp);..
[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] 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..
[BOJ] 9205번: 맥주 마시면서 걸어가기 (JAVA) https://www.acmicpc.net/problem/9205 9205번: 맥주 마시면서 걸어가기 송도에 사는 상근이와 친구들은 송도에서 열리는 펜타포트 락 페스티벌에 가려고 한다. 올해는 맥주를 마시면서 걸어가기로 했다. 출발은 상근이네 집에서 하고, 맥주 한 박스를 들고 출발한다. www.acmicpc.net import java.io.*; import java.util.*; class Point{ int x; int y; Point(int x, int y){ this.x = x; this.y = y; } } public class Main { //맨헤튼 거리 안에 갈 수 있는 정점을 연결해준다, 맥주 20개 * 50m = 1000m static ArrayList arr; static ArrayL..