본문 바로가기

알고리즘113

[프로그래머스] 특정 문자 제거하기 [프로그래머스]문제 :https://school.programmers.co.kr/learn/courses/30/lessons/120826 프로그래머스SW개발자를 위한 평가, 교육, 채용까지 Total Solution을 제공하는 개발자 성장을 위한 베이스캠프programmers.co.kr오... 오랜만에 하니까. 프로그래머스 썸네일이 바꼈네용? 싱기 해결 :import java.util.*;class Solution { public String solution(String my_string, String letter) { String[] answer = my_string.split(""); String result = ""; for(String i : answer.. 2025. 2. 24.
[프로그래머스] 추억 점수 문제 :https://school.programmers.co.kr/learn/courses/30/lessons/176963 프로그래머스코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.programmers.co.kr  해결 :import java.util.HashMap;class Solution { public int[] solution(String[] name, int[] yearning, String[][] photo) { int[] answer = new int[photo.length]; HashMap score = new HashMap(); .. 2024. 5. 17.
[프로그래머스] 소수 찾기 문제 : https://school.programmers.co.kr/learn/courses/30/lessons/42839 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 해결 : import java.util.*; class Solution { public int solution(String numbers) { // 결과를 저장할 set(중복 제거) Set primeSet = new HashSet(); // 숫자로 만들 수 있는 모든 순열을 구하고, 소수인 경우 set에 추가 permutation("", numbers, primeSet); // 소수의 개.. 2024. 4. 14.
[프로그래머스] 카펫 문제 : https://school.programmers.co.kr/learn/courses/30/lessons/42842 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 해결 : class Solution { public int[] solution(int brown, int yellow) { int[] answer = new int[2]; int total = brown + yellow; for (int i = 1; i 2024. 4. 14.
[프로그래머스] 피로도 문제 : https://school.programmers.co.kr/learn/courses/30/lessons/87946 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 해결 : class Solution { //깊이 우선 탐색(DFS) static int answer = 0; static boolean[] visited; static boolean flag = false; public int solution(int k, int[][] dungeons) { //방문 배열 visited = new boolean[dungeons.length]; dfs(0,k.. 2024. 4. 14.
[프로그래머스] 최소직사각형 문제 : https://school.programmers.co.kr/learn/courses/30/lessons/86491 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 해결 : class Solution { public int solution(int[][] sizes) { int ga = sizes[0][0]; int se = sizes[0][1]; //가로, 세로 중에 가장 큰 길이를 골라서. 기준 길이로 잡는다. for(int i = 0; i 2024. 4. 13.
[프로그래머스] 모의고사 문제 : https://school.programmers.co.kr/learn/courses/30/lessons/42840 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 해결 : import java.util.*; class Solution { public int[] solution(int[] answers) { int[] one = {1,2,3,4,5}; int[] two = {2,1,2,3,2,4,2,5}; int[] thr = {3,3,1,1,2,2,4,4,5,5}; int[] score = {0,0,0}; for(int i = 0 ; i 2024. 4. 10.
[프로그래머스] H-Index 문제 : https://school.programmers.co.kr/learn/courses/30/lessons/42747 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 해결 : import java.util.Arrays; class Solution { public int solution(int[] citations) { int answer = 0; int len = citations.length; Arrays.sort(citations); for(int i = 0; i= h){ answer = h; break; } } return answer; } } .. 2024. 3. 24.
[프로그래머스] 예산 문제 : https://school.programmers.co.kr/learn/courses/30/lessons/12982 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 해결1 : import java.util.Arrays; class Solution { public int solution(int[] d, int budget) { int answer = 0; int depart = 0; Arrays.sort(d); for(int i : d){ answer += i; if(budget >= answer){ ++depart; }else{ break; } } .. 2024. 3. 24.
[프로그래머스] 음양 더하기 문제 : https://school.programmers.co.kr/learn/courses/30/lessons/76501 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 해결 : class Solution { public int solution(int[] absolutes, boolean[] signs) { int answer = 0; for(int i = 0; i 2024. 3. 24.
[프로그래머스] 정렬 > 가장 큰 수 문제 :https://school.programmers.co.kr/learn/courses/30/lessons/42746 프로그래머스코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.programmers.co.kr 해결 :import java.util.*;class Solution { public String solution(int[] numbers) { String[] answer = new String[numbers.length]; for(int i =0; i(o2+o1).compareTo(o1+o2)); if(answer[0]... 2024. 3. 21.
[프로그래머스] 정렬 > K번째수 문제 :https://school.programmers.co.kr/learn/courses/30/lessons/42748 프로그래머스코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.programmers.co.kr 해결 :import java.util.Arrays;class Solution { public int[] solution(int[] array, int[][] commands) { int[] answer = new int[commands.length]; for(int i = 0; i 2024. 3. 20.