코딩테스트

코딩테스트/프로그래머스

[프로그래머스] 전화번호 목록 - JAVA

문제 https://school.programmers.co.kr/learn/courses/30/lessons/42577 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 코드 1. HashSet 이용하여 풀기 HashSet에 전화번호들을 모두 다 저장한다. 그리고 각 전화번호에 대해 처음부터 substring 한 값이 set에 있으면 접두어이므로 false를 리턴한다 import java.util.*; class Solution { public boolean solution(String[] phone_book) { HashSet hash = new HashS..

코딩테스트/프로그래머스

[프로그래머스] 타겟 넘버 - JAVA

문제 https://school.programmers.co.kr/learn/courses/30/lessons/43165 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 코드 class Solution { int result = 0; int target; public int solution(int[] numbers, int target) { this.target = target; makeTargetNumber(0, 0, numbers); return result; } public void makeTargetNumber(int cnt, int ans, int ..

코딩테스트/프로그래머스

[프로그래머스] 이중우선순위큐 - JAVA

문제 https://school.programmers.co.kr/learn/courses/30/lessons/42628 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 코드 import java.util.*; class Solution { public int[] solution(String[] operations) { List pq = new LinkedList(); for(int i=0;i

코딩테스트/프로그래머스

[프로그래머스] 정수 삼각형 - JAVA

문제 https://school.programmers.co.kr/learn/courses/30/lessons/43105 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 코드 class Solution { public int solution(int[][] triangle) { int dp [][] = new int [triangle.length][triangle.length]; dp[0][0] = triangle[0][0]; dp[1][0] = triangle[1][0] + dp[0][0]; dp[1][1] = triangle[1][1] + dp[0][0];..

코딩테스트/프로그래머스

[프로그래머스] 피로도 - JAVA

문제 https://school.programmers.co.kr/learn/courses/30/lessons/87946 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 코드 class Solution { boolean visited []; int [][] array; int result; public int solution(int k, int[][] dungeons) { visited = new boolean [dungeons.length]; array = dungeons; explore(0, k); int answer = result; return ans..

코딩테스트/프로그래머스

[프로그래머스] [1차] 뉴스 클러스터링 - JAVA

문제 https://school.programmers.co.kr/learn/courses/30/lessons/17677 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 풀이 1. 대문자와 소문자의 차이는 무시한다. 따라서 toUpperCase()를 이용하여 영문자들은 대문자로 바꿔준다. 2. 입력으로 들어온 문자열은 두 글자씩 원소로 만든다. 이는 substring 함수를 이용하여 문자열을 2글자씩 추출한다. 3. 영문자로만 된 글자쌍만 유효하므로 matches함수를 이용하여 영문자로만 된 글자쌍이면 list에 넣는다. 매개변수로 들어오는 str1과 str..

코딩테스트/프로그래머스

[프로그래머스] 프로세스 - JAVA

문제 https://school.programmers.co.kr/learn/courses/30/lessons/42587 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 코드 import java.util.*; class Solution { public int solution(int[] priorities, int location) { Queue que = new LinkedList(); for(int i=0;i

코딩테스트/프로그래머스

[프로그래머스] 기능개발 - JAVA

문제 https://school.programmers.co.kr/learn/courses/30/lessons/42586 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 코드 import java.util.*; class Solution { public List solution(int[] progresses, int[] speeds) { Stack stack = new Stack(); List list = new ArrayList(); int n = progresses.length; int res = 0; for(int i=0;i

코딩테스트/프로그래머스

[프로그래머스] 할인 행사 - JAVA

문제 https://school.programmers.co.kr/learn/courses/30/lessons/131127 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 코드 -map을 이용할 경우 want를 넣은 map과 discount를 넣은 map에 대해서 같은 key의 value 값에 대해서 비교 실제 개수가 더 크면 answer를 update import java.util.*; class Solution { public int solution(String[] want, int[] number, String[] discount) { int answe..

코딩테스트/프로그래머스

[프로그래머스] 튜플 - JAVA

문제 https://school.programmers.co.kr/learn/courses/30/lessons/64065 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 코드 import java.util.*; class Solution { public int[] solution(String s) { List list = new LinkedList(); String arr [] = s.replaceAll("[{}]", " ").trim().split(" ,"); Arrays.sort(arr,new Comparator(){ public int compare(S..