Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | |||||
3 | 4 | 5 | 6 | 7 | 8 | 9 |
10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 20 | 21 | 22 | 23 |
24 | 25 | 26 | 27 | 28 | 29 | 30 |
31 |
Tags
- sns
- Validation
- Lamda
- CHECK
- serverless
- amazonqcli
- 병목
- lambda
- fcm
- cloudwatch
- aws
- kubernetes
- SageMaker
- rds
- IaC
- terraform
Archives
- Today
- Total
잡다한 IT 지식
프로그래머스 - 직업군 추천하기 본문
본 알고리즘 풀이는 Routine Study에서 진행하고 있습니다.
저를 포함한 구성원이 대부분 초보이므로, 원하시는분은 언제라도 들어오셔도 좋습니다.
문의는 댓글 바람.
GitHub - ROUTINE-STUDY/Algorithm: 초보 알고리즘 스터디 / 누구나 참여 가능
초보 알고리즘 스터디 / 누구나 참여 가능 :runner:. Contribute to ROUTINE-STUDY/Algorithm development by creating an account on GitHub.
github.com
코딩테스트 연습 - 4주차
개발자가 사용하는 언어와 언어 선호도를 입력하면 그에 맞는 직업군을 추천해주는 알고리즘을 개발하려고 합니다. 아래 표는 5개 직업군 별로 많이 사용하는 5개 언어에 직업군 언어 점수를 부
programmers.co.kr
[문제 설명]
그냥 구현해주면 되는 문제같습니다. 딱히 뭔가를 해줘야 하는 문제 같지는 않습니다.
배열을 써도 되겠지만, Map을 써서 풀어봤습니다.
[처음 생각한 접근 방법]
import java.util.*;
class Solution {
public String solution(String[] table, String[] languages, int[] preference) {
String answer = "";
Map<String,Map<String, Integer>> database = new HashMap<>();
for (String company : table) {
int score = 5;
String[] sArray = company.split(" ");
Map<String, Integer> tempMap = new HashMap();
for (int i = 1; i < sArray.length; i++) {
tempMap.put(sArray[i], score--);
}
database.put(sArray[0],tempMap);
}
Map<String, Integer> jobScoreMap = new HashMap<>();
for (String key : database.keySet()) {
Map<String,Integer> tempMap = database.get(key);
int totalScore = 0;
for (int i = 0; i < languages.length; i++) {
totalScore += tempMap.getOrDefault(languages[i],0) * (preference[i]);
}
jobScoreMap.put(key, totalScore);
}
int max = 0;
for (int score : jobScoreMap.values()) {
if (score > max) {
max = score;
}
}
List<String> highPointJob = new ArrayList<>();
for (String job : jobScoreMap.keySet()) {
if (jobScoreMap.get(job) == max) highPointJob.add(job);
}
Collections.sort(highPointJob);
return highPointJob.get(0);
}
}
'알고리즘 문제 풀이' 카테고리의 다른 글
알고리즘 기본 - 에라토스테네스의 체 (0) | 2022.01.19 |
---|---|
530. Minimum Absolute Difference in BST (0) | 2021.10.18 |
프로그래머스 - 폰켓몬 (0) | 2021.07.27 |
프로그래머스 약수의 개수와 덧셈 (0) | 2021.07.24 |
104. Maximum Depth of Binary Tree (0) | 2021.06.29 |