🙈

⃝ 동글동글 ⃝

🪐ᐩ˖ 🍎
728x90
반응형
SMALL

CodingTest 34

[프로그래머스 고득점 Kit] 프로세스 - Stack/Queue - Lv2

⭐️ 코드 import java.util.*; class Solution { private static class Node { int priority; int idx; public Node(int priority, int idx) { this.priority = priority; this.idx = idx; } } public int solution(int[] priorities, int location) { int answer = 0; ArrayDeque queue = new ArrayDeque(); for (int i = 0; i < priorities.length; i++) { queue.add(new Node(priorities[i], i)); } // 숫자가 높을 수록 우선순위가 높음 while..

[프로그래머스 고득점 Kit] 기능개발 - Stack/Queue - Lv2

⭐️ 코드 (Queue 이용) import java.util.*; class Solution { public int[] solution(int[] progresses, int[] speeds) { ArrayDeque queue = new ArrayDeque(); ArrayDeque speedsQueue = new ArrayDeque(); for (int i = 0; i < progresses.length; i++) { queue.addLast(progresses[i]); speedsQueue.addLast(speeds[i]); } ArrayList arrayList = new ArrayList(); while (!queue.isEmpty()) { for (int i = 0; i < queue.size()..

[프로그래머스 고득점 Kit] 베스트앨범 - Hash(해시) - Lv3

⭐️ 코드 (HashSet 이용) 정답 코드지만 직접 풀어보면서 출력해 봤던 테스트 코드!! 이번 문제는 완전 리스트와 해시맵의 중첩이었다... import java.util.*; public class 베스트앨범 { static class Solution { private static class Node { int idx; String genre; int play; public Node(int idx, String genre, int play) { this.idx = idx; this.genre = genre; this.play = play; } @Override public String toString() { return "Node{" + "idx=" + idx + ", genre='" + genre..

[프로그래머스 고득점 Kit] 의상 - Hash(해시) - Lv2

⭐️ 코드 (HashSet 이용) 1. HashMap에 옷의 종류별로 개수를 카운트한다. 2. 해당 옷을 안 입는 경우도 있기 때문에 경우의 수 + 1을 해준다. 3. 모든 옷을 안 입는 경우는 없기 때문에 결과 -1을 해서 개수 세기! import java.util.*; class Solution { public int solution(String[][] clothes) { int answer = 0; HashMap hashMap = new HashMap(); for (int i = 0; i < clothes.length; i++) { hashMap.put(clothes[i][1], hashMap.getOrDefault(clothes[i][1], 0) + 1); } int count = 1; for (..

[프로그래머스 고득점 Kit] 전화번호 목록 - Hash(해시) - Lv2

⭐️ 코드 (HashSet 이용) import java.util.*; class Solution { public boolean solution(String[] phone_book) { boolean answer = true; HashSet hashSet = new HashSet(); for (int i = 0; i < phone_book.length; i++) { hashSet.add(phone_book[i]); } for (int i = 0; i < phone_book.length; i++) { for (int j = 0; j < phone_book[i].length(); j++) { if (hashSet.contains(phone_book[i].substring(0, j))) { return fals..

[백준 / 11650번] 좌표 정렬하기 - (Java - TimSort - 정렬)

11650번: 좌표 정렬하기 첫째 줄에 점의 개수 N (1 ≤ N ≤ 100,000)이 주어진다. 둘째 줄부터 N개의 줄에는 i번점의 위치 xi와 yi가 주어진다. (-100,000 ≤ xi, yi ≤ 100,000) 좌표는 항상 정수이고, 위치가 같은 두 점은 없다. www.acmicpc.net ⭐️ 코드 import java.io.*; import java.util.Arrays; import java.util.StringTokenizer; // 좌표 정렬하기 - 실버5 public class Main { private static class Coordinate{ int x, y; public Coordinate(int x, int y) { this.x = x; this.y = y; } } public..

CodingTest/BOJ 2023.02.08

[백준 / 10989번] 수 정렬하기 3 - (Java - Counting Sort / 개수 정렬)

10989번: 수 정렬하기 3 첫째 줄에 수의 개수 N(1 ≤ N ≤ 10,000,000)이 주어진다. 둘째 줄부터 N개의 줄에는 수가 주어진다. 이 수는 10,000보다 작거나 같은 자연수이다. www.acmicpc.net ⭐️ 코드 // 수 정렬하기 3 // Counting Sort - 개수 정렬 // 배열의 사이즈가 작고, 숫자의 범위가 10_000 이하일 때 사용 가능 // 배열에 입력된 동일한 숫자의 개수를 count 해서 배열이 0이 아닌것을 // 순서대로 count 수만큼 반복 출력하는 것 import java.io.*; import java.util.StringTokenizer; import java.util.*; public class 수_정렬하기3 { private static fina..

CodingTest/BOJ 2023.02.08

[프로그래머스/Programmers] 구명보트 (Java - Greedy - Lv2)

구명보트 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr ⭐️ 코드 import java.util.Arrays; class Solution { public int solution(int[] people, int limit) { int answer = 0; Arrays.sort(people); int j = 0; for (int i = people.length-1; i>=j; i--) { if (people[j] + people[i] =j; i--) { if (people[j] + people[i]

[프로그래머스/Programmers] 카펫 (Java - 완전탐색 - Lv2)

카펫 - 완전탐색 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr ⭐️ 코드 class Solution { public int[] solution(int brown, int yellow) { int[] answer = new int[2]; int tileSum = brown+yellow; // 전체 타일 개수 int yellow_sqrt = (int)Math.sqrt(yellow); for(int i = yellow_sqrt; i>0; i--) { for (int j = yellow_sqrt; j 0; i--) { for (int j = yellow_sqr..

[프로그래머스/Programmers] 가장 큰 수 (Java - 정렬 - Lv2)

가장 큰 수 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr ⭐️ 코드 - 프로그래머스에서 빌드할 때는 출력문은 다 지우고 하셔야 합니다. package Programmers.Level_2; import java.util.*; public class PL2_17 { // Level2 가장 큰 수 public String solution(int[] numbers) { // numbers 배열을 String 변환 String[] sArr = new String[numbers.length]; for (int i = 0; i < sArr.length; i++) {..

728x90
반응형
LIST